Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2022-12-16 21:42:18
Exec Total Coverage
Lines: 7592 16455 46.1%
Functions: 203 316 64.2%
Branches: 5901 19768 29.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // Zelda Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #ifndef __GTHREAD_HIDE_WIN32API
16 13 #define __GTHREAD_HIDE_WIN32API 1
17 #endif //prevent indirectly including windows.h
18
19 #include "precompiled.h" //always first
20
21 #include <string.h>
22 #include <set>
23 #include <stdio.h>
24
25 #include "hero.h"
26 #include "guys.h"
27 #include "subscr.h"
28 #include "zc_subscr.h"
29 #include "decorations.h"
30 #include "gamedata.h"
31 #include "zc_custom.h"
32 #include "title.h"
33 #include "ffscript.h"
34 #include "drawing.h"
35 #include "combos.h"
36 #include "base/zc_math.h"
37 #include "user_object.h"
38 #include "slopes.h"
39 extern FFScript FFCore;
40 extern word combo_doscript[176];
41 extern byte itemscriptInitialised[256];
42 extern HeroClass Hero;
43 extern ZModule zcm;
44 extern zcmodule moduledata;
45 extern refInfo playerScriptData;
46 #include "zscriptversion.h"
47 #include "particles.h"
48 #include <fmt/format.h>
49
50 extern refInfo itemScriptData[256];
51 extern refInfo itemCollectScriptData[256];
52 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
53 extern int32_t item_collect_stack[256][MAX_SCRIPT_REGISTERS];
54 extern refInfo *ri; //= NULL;
55 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
56 extern byte dmapscriptInitialised;
57 extern word item_doscript[256];
58 extern word item_collect_doscript[256];
59 extern portal* mirror_portal;
60 using std::set;
61
62 extern int32_t skipcont;
63
64 extern int32_t draw_screen_clip_rect_x1;
65 extern int32_t draw_screen_clip_rect_x2;
66 extern int32_t draw_screen_clip_rect_y1;
67 extern int32_t draw_screen_clip_rect_y2;
68 extern word global_wait;
69 extern bool player_waitdraw;
70 extern bool dmap_waitdraw;
71 extern bool passive_subscreen_waitdraw;
72 extern bool active_subscreen_waitdraw;
73
74 int32_t hero_count = -1;
75 int32_t hero_animation_speed = 1; //lower is faster animation
76 int32_t z3step = 2;
77 13 static zfix hero_newstep(1.5);
78 13 static zfix hero_newstep_diag(1.5);
79 bool did_scripta=false;
80 bool did_scriptb=false;
81 bool did_scriptl=false;
82 byte lshift = 0;
83 int32_t dowpn = -1;
84 int32_t directItem = -1; //Is set if Hero is currently using an item directly
85 int32_t directItemA = -1;
86 int32_t directItemB = -1;
87 int32_t directItemX = -1;
88 int32_t directItemY = -1;
89 int32_t directWpn = -1;
90 int32_t whistleitem=-1;
91 extern word g_doscript;
92 extern word player_doscript;
93 extern word dmap_doscript;
94 extern word passive_subscreen_doscript;
95 extern byte epilepsyFlashReduction;
96 extern int32_t script_hero_cset;
97
98 void playLevelMusic();
99
100 extern particle_list particles;
101
102 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
103
104 #define CANFORCEFACEUP (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
105 #define NO_GRIDLOCK (get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
106 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
107 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_bit(quest_rules,qr_BROKEN_Z3_ANIMATION))
108
109 282876 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
110 {
111
2/2
✓ Branch 0 taken 12627 times.
✓ Branch 1 taken 270249 times.
282876 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
112 270249 return false;
113 282876 }
114
115 99815 static inline bool platform_fallthrough(bool doslopecheck = true)
116 {
117
5/6
✓ Branch 0 taken 99815 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93777 times.
✓ Branch 3 taken 6038 times.
✓ Branch 4 taken 89260 times.
✓ Branch 5 taken 4517 times.
276725 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
118
2/2
✓ Branch 0 taken 12930 times.
✓ Branch 1 taken 6892 times.
99815 || (getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
119
6/6
✓ Branch 0 taken 78544 times.
✓ Branch 1 taken 91474 times.
✓ Branch 2 taken 217 times.
✓ Branch 3 taken 98149 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 39 times.
19822 || (Hero.jumping < 0 && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
120 }
121
122 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
123 {
124 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
125 if(slopesmisc == 2) return false;
126 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
127 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
128 if (platform_fallthrough() && !ignoreFallthrough) return false;
129 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
130 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
131 return true;
132 return false;
133 }
134
135 173127 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
136 {
137
4/4
✓ Branch 0 taken 85282 times.
✓ Branch 1 taken 87845 times.
✓ Branch 2 taken 54352 times.
✓ Branch 3 taken 30930 times.
173127 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
138
2/2
✓ Branch 0 taken 2426 times.
✓ Branch 1 taken 139771 times.
142197 if(slopesmisc == 2) return false;
139
4/4
✓ Branch 0 taken 101602 times.
✓ Branch 1 taken 38169 times.
✓ Branch 2 taken 1777 times.
✓ Branch 3 taken 99825 times.
139771 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
140
6/6
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 99698 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 10 times.
99825 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
141
4/4
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 98327 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 1278 times.
99815 if (platform_fallthrough() && !ignoreFallthrough) return false;
142
4/4
✓ Branch 0 taken 28268 times.
✓ Branch 1 taken 70269 times.
✓ Branch 2 taken 27038 times.
✓ Branch 3 taken 1230 times.
98537 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
143
6/6
✓ Branch 0 taken 30151 times.
✓ Branch 1 taken 67156 times.
✓ Branch 2 taken 21397 times.
✓ Branch 3 taken 8754 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 21384 times.
97307 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
144 8767 return true;
145 88540 return false;
146 173127 }
147
148
149 230884 bool usingActiveShield(int32_t itmid)
150 {
151
2/2
✓ Branch 0 taken 200247 times.
✓ Branch 1 taken 30637 times.
230884 switch(Hero.action) //filter allowed actions
152 {
153 case none: case walking: case rafting:
154 case gothit: case swimhit:
155 200247 break;
156 30637 default: return false;
157 }
158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200247 times.
200247 if(itmid < 0)
159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200247 times.
200247 itmid = (Hero.active_shield_id < 0
160 200247 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
161
2/2
✓ Branch 0 taken 197418 times.
✓ Branch 1 taken 2829 times.
200247 if(itmid < 0) return false;
162
1/2
✓ Branch 0 taken 197418 times.
✗ Branch 1 not taken.
197418 if(!checkitem_jinx(itmid)) return false;
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 197418 times.
197418 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
164 if(!isItmPressed(itmid)) return false;
165 return (checkbunny(itmid) && checkmagiccost(itmid));
166 230884 }
167 142401 int32_t getCurrentShield(bool requireActive)
168 {
169
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
142401 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
170 return Hero.active_shield_id;
171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142401 times.
142401 if(!requireActive) return current_item_id(itype_shield);
172 return -1;
173 142401 }
174 8595 int32_t getCurrentActiveShield()
175 {
176 8595 int32_t id = Hero.active_shield_id;
177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8595 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8595 if(id > -1 && usingActiveShield(id))
178 return id;
179 8595 return -1;
180 8595 }
181 79964 int32_t refreshActiveShield()
182 {
183 79964 int32_t id = -1;
184
2/2
✓ Branch 0 taken 76191 times.
✓ Branch 1 taken 3773 times.
79964 if(DrunkcBbtn())
185 {
186 3773 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
187
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3773 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3773 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
188 {
189 id = Bwpn&0xFFF;
190 }
191 3773 }
192
3/4
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72908 times.
✓ Branch 3 taken 7056 times.
79964 if(id < 0 && DrunkcAbtn())
193 {
194 7056 itemdata const& dat = itemsbuf[Awpn&0xFFF];
195
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7056 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7056 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
196 {
197 id = Awpn&0xFFF;
198 }
199 7056 }
200
3/4
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79959 times.
✓ Branch 3 taken 5 times.
79964 if(id < 0 && DrunkcEx1btn())
201 {
202 5 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
203
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
204 {
205 id = Xwpn&0xFFF;
206 }
207 5 }
208
3/4
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79958 times.
✓ Branch 3 taken 6 times.
79964 if(id < 0 && DrunkcEx2btn())
209 {
210 6 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
211
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
212 {
213 id = Ywpn&0xFFF;
214 }
215 6 }
216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
79964 if(!usingActiveShield(id))
217 79964 return -1;
218 return id;
219 79964 }
220 static bool is_immobile()
221 {
222 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
223 return false;
224 zfix rate(Hero.steprate);
225 int32_t shieldid = getCurrentActiveShield();
226 if(shieldid > -1)
227 {
228 itemdata const& shield = itemsbuf[shieldid];
229 if(shield.flags & ITEM_FLAG10) //Change Speed flag
230 {
231 zfix perc = shield.misc7;
232 perc /= 100;
233 if(perc < 0)
234 perc = (perc*-1)+1;
235 rate = (rate * perc) + shield.misc8;
236 }
237 }
238 return rate != 0;
239 }
240
241 92393 bool HeroClass::isStanding(bool forJump)
242 {
243
10/14
✓ Branch 0 taken 92393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13949 times.
✓ Branch 5 taken 78444 times.
✓ Branch 6 taken 5289 times.
✓ Branch 7 taken 8660 times.
✓ Branch 8 taken 5289 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5289 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 428 times.
✓ Branch 13 taken 4861 times.
92393 bool st = (z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !ladderx && !laddery && !getOnSideviewLadder()) && hoverclk==0);
244
2/2
✓ Branch 0 taken 87532 times.
✓ Branch 1 taken 4861 times.
92393 if(!st) return false;
245 87532 int32_t val = check_pitslide();
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87532 times.
87532 if(val == -2) return false;
247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87532 times.
87532 if(val == -1) return true;
248 return forJump;
249 92393 }
250 12968 bool HeroClass::isLifting()
251 {
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12968 times.
12968 if(lift_wpn) return true;
253 12968 return false;
254 12968 }
255
256 13223 void HeroClass::set_respawn_point(bool setwarp)
257 {
258
2/2
✓ Branch 0 taken 13105 times.
✓ Branch 1 taken 118 times.
13223 if(setwarp)
259 {
260 118 warpx = x;
261 118 warpy = y;
262 118 raftwarpx = x;
263 118 raftwarpy = y;
264 118 }
265
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 13005 times.
13223 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
266 {
267
2/2
✓ Branch 0 taken 12852 times.
✓ Branch 1 taken 153 times.
13005 switch(action)
268 {
269 case none: case walking:
270 12852 break;
271 default:
272 153 return; //Not a 'safe action'
273 }
274
3/6
✓ Branch 0 taken 12852 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12852 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12852 times.
12852 if(z > 0 || fakez > 0 || hoverclk) return; //in air
275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12852 times.
12852 if(check_pitslide(true) != -1) return; //On a pit
276
277 { //Check water
278 12852 int32_t water = 0;
279 12852 int32_t types[4] = {0};
280 12852 int32_t x1 = x+4, x2 = x+11,
281 12852 y1 = y+9, y2 = y+15;
282
1/2
✓ Branch 0 taken 12852 times.
✗ Branch 1 not taken.
12852 if (get_bit(quest_rules, qr_SMARTER_WATER))
283 {
284
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 12831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
12854 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
285
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 19 times.
21 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
286
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
287 2 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
288 12852 }
289 else
290 {
291 types[0] = COMBOTYPE(x1,y1);
292
293 if(MAPFFCOMBO(x1,y1))
294 types[0] = FFCOMBOTYPE(x1,y1);
295
296 types[1] = COMBOTYPE(x1,y2);
297
298 if(MAPFFCOMBO(x1,y2))
299 types[1] = FFCOMBOTYPE(x1,y2);
300
301 types[2] = COMBOTYPE(x2,y1);
302
303 if(MAPFFCOMBO(x2,y1))
304 types[2] = FFCOMBOTYPE(x2,y1);
305
306 types[3] = COMBOTYPE(x2,y2);
307
308 if(MAPFFCOMBO(x2,y2))
309 types[3] = FFCOMBOTYPE(x2,y2);
310
311 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
312 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
313 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
314
315 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
316 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
317 water = typec;
318 }
319
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12850 times.
12852 if(water > 0)
320 {
321 2 return;
322 }
323 } //End check water
324
325 64250 int poses[4] = {
326 12850 COMBOPOS(x,y+(bigHitbox?0:8)),
327 12850 COMBOPOS(x,y+15),
328 12850 COMBOPOS(x+15,y+(bigHitbox?0:8)),
329 12850 COMBOPOS(x+15,y+15)
330 };
331
2/2
✓ Branch 0 taken 51400 times.
✓ Branch 1 taken 12850 times.
64250 for(auto pos : poses)
332 {
333
1/2
✓ Branch 0 taken 51400 times.
✗ Branch 1 not taken.
51400 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
334 return;
335 }
336 12850 }
337 13068 respawn_x = x;
338 13068 respawn_y = y;
339 13068 respawn_scr = currscr;
340 13068 respawn_dmap = currdmap;
341 13223 }
342
343 2 void HeroClass::go_respawn_point()
344 {
345 2 x = respawn_x;
346 2 y = respawn_y;
347 2 can_mirror_portal = false; //incase entry is on a portal!
348 2 warpx=x;
349 2 warpy=y;
350 2 raftwarpx = x;
351 2 raftwarpy = y;
352 2 trySideviewLadder(); //Cling to ladder automatically
353
354
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_bit(quest_rules, qr_OLD_RESPAWN_POINTS))
355 return; //No cross-screen return
356
357
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(currdmap != respawn_dmap || currscr != respawn_scr)
358 {
359 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
360 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
361 }
362 2 }
363
364 130 void HeroClass::trySideviewLadder()
365 {
366
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
130 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
367 setOnSideviewLadder(true);
368 130 }
369
370 385286 bool HeroClass::can_pitfall(bool ignore_hover)
371 {
372
17/30
✓ Branch 0 taken 351914 times.
✓ Branch 1 taken 33372 times.
✓ Branch 2 taken 351914 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351914 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351914 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 351914 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 351914 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 351914 times.
✓ Branch 14 taken 351914 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 351914 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 351914 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 351914 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 351914 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 351914 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 351914 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 512 times.
✓ Branch 29 taken 351402 times.
385286 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
373 }
374
375 44500 int32_t HeroClass::DrunkClock()
376 {
377 44500 return drunkclk;
378 }
379 void HeroClass::setDrunkClock(int32_t newdrunkclk)
380 {
381 drunkclk=newdrunkclk;
382 }
383
384 int32_t HeroClass::StunClock()
385 {
386 return lstunclock;
387 }
388 void HeroClass::setStunClock(int32_t v)
389 {
390 lstunclock=v;
391 }
392
393 376603 int32_t HeroClass::BunnyClock()
394 {
395 376603 return lbunnyclock;
396 }
397 void HeroClass::setBunnyClock(int32_t v)
398 {
399 lbunnyclock=v;
400 }
401
402
9/18
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 13 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 13 times.
✗ Branch 17 not taken.
52 HeroClass::HeroClass() : sprite()
403 39 {
404 13 lift_wpn = nullptr;
405
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 init();
406 26 }
407
408 //2.6
409
410 //Stop the subscreen from falling. -Z
411
412 2 bool HeroClass::stopSubscreenFalling(){
413 2 return preventsubscreenfalling;
414 }
415
416 void HeroClass::stopSubscreenFalling(bool v){
417 preventsubscreenfalling = v;
418 }
419
420
421 //Set the button items by brute force
422
423 void HeroClass::setAButtonItem(int32_t itmslot){
424 game->awpn = itmslot;
425 }
426
427 void HeroClass::setBButtonItem(int32_t itmslot){
428 game->bwpn = itmslot;
429 }
430
431 79964 void HeroClass::ClearhitHeroUIDs()
432 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
433 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
434 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
435 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
436 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
437 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
438 //clear it on the next frame, but that had the SAME outcome.
439 //Where and how can I clear a value at the end of every frame, so that:
440 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
441 // 2. FFCs can read it before Waitframe. --same.
442 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
443
2/2
✓ Branch 0 taken 639712 times.
✓ Branch 1 taken 79964 times.
719676 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED_PLAYER; q++ )
444 {
445 /*
446 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
447 {
448 //Z_scripterrlog("frame is: %d\n", frame);
449 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
450 lastHitBy[q][0] = 0;
451 }
452 */
453 639712 lastHitBy[q][0] = 0;
454 639712 }
455 79964 }
456
457 54 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
458 {
459 54 lastHitBy[type][0] = screen_index;
460 //lastHitBy[type][1] = frame;
461 /* Let's figure out how to clear this...
462 if ( global_wait ) lastHitBy[type] = screen_index;
463 else lastHitBy[type] = 0;
464 //No, we clear it in Zelda.cpp, with this:
465 if(global_wait)
466 {
467 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
468 global_wait=false;
469 }
470
471
472 draw_screen(tmpscr);
473
474 //clear Hero's last hits
475 //for ( int32_t q = 0; q < 4; q++ ) Hero.sethitHeroUID(q, 0);
476
477 */
478
479 54 }
480
481 int32_t HeroClass::gethitHeroUID(int32_t type)
482 {
483 return lastHitBy[type][0];
484 }
485
486 void HeroClass::set_defence(int32_t type, int32_t v)
487 {
488 defence[type] = v;
489 }
490
491 int32_t HeroClass::get_defence(int32_t type)
492 {
493 return defence[type];
494 }
495
496
497 //Set Hero;s hurt sfx
498 void HeroClass::setHurtSFX(int32_t sfx)
499 {
500 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
501 }
502 32 int32_t HeroClass::getHurtSFX()
503 {
504 32 return QMisc.miscsfx[sfxHURTPLAYER];
505 }
506
507 bool HeroClass::getDiagMove()
508 {
509 return diagonalMovement;
510 }
511 void HeroClass::setDiagMove(bool newdiag)
512 {
513 diagonalMovement=newdiag;
514 }
515 9024 bool HeroClass::getBigHitbox()
516 {
517 9024 return bigHitbox;
518 }
519 31 void HeroClass::setBigHitbox(bool newbigHitbox)
520 {
521 31 bigHitbox=newbigHitbox;
522 31 syofs = bigHitbox?0:8;
523 31 sysz_ofs = bigHitbox?0:-8;
524 31 }
525 int32_t HeroClass::getStepRate()
526 {
527 return steprate;
528 }
529 void HeroClass::setStepRate(int32_t newrate)
530 {
531 steprate = newrate;
532 }
533 int32_t HeroClass::getSwimUpRate()
534 {
535 return game->get_sideswim_up();
536 }
537 void HeroClass::setSwimUpRate(int32_t newrate)
538 {
539 game->set_sideswim_up(newrate);
540 }
541 int32_t HeroClass::getSwimSideRate()
542 {
543 return game->get_sideswim_side();
544 }
545 void HeroClass::setSwimSideRate(int32_t newrate)
546 {
547 game->set_sideswim_side(newrate);
548 }
549 int32_t HeroClass::getSwimDownRate()
550 {
551 return game->get_sideswim_down();
552 }
553 void HeroClass::setSwimDownRate(int32_t newrate)
554 {
555 game->set_sideswim_down(newrate);
556 }
557
558
559 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
560 62688 void HeroClass::herostep()
561 {
562
2/2
✓ Branch 0 taken 57655 times.
✓ Branch 1 taken 5033 times.
62688 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
563 //need to run all global/hero/dmap scripts here?
564 62688 }
565
566 296 bool is_moving()
567 {
568
6/6
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 144 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 25 times.
296 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
569 }
570
571 // called by ALLOFF()
572 192 void HeroClass::resetflags(bool all)
573 {
574 192 refilling=REFILL_NONE;
575 192 inwallm=false;
576 192 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
577 192 usecounts.clear();
578
579
3/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 175 times.
192 if(swordclk>0 || all)
580 {
581 17 swordclk=0;
582 17 verifyAWpn();
583 17 }
584
3/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 175 times.
192 if(itemclk>0 || all)
585 17 itemclk=0;
586
587
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 17 times.
192 if(all)
588 {
589 17 NayrusLoveShieldClk=0;
590
591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(nayruitem != -1)
592 {
593 stop_sfx(itemsbuf[nayruitem].usesound);
594 stop_sfx(itemsbuf[nayruitem].usesound+1);
595 }
596
597 17 nayruitem = -1;
598 17 hoverclk=jumping=0;
599 17 hoverflags = 0;
600 17 }
601 192 damageovertimeclk = 0;
602 192 newconveyorclk = 0;
603 192 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
604
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 1344 times.
1536 for(auto q = 0; q < 7; ++q)
605 1344 hooked_undercombos[q] = -1;
606 192 hopclk=0;
607 192 hopdir=-1;
608 192 attackclk=0;
609 192 stomping=false;
610 192 reset_swordcharge();
611 192 diveclk=drownclk=drownCombo=0;
612 192 action=none; FFCore.setHeroAction(none);
613 192 conveyor_flags=0;
614 192 magiccastclk=0;
615 192 magicitem=-1;
616 192 }
617
618 //Can use this for Hero->Stun. -Z
619 80 void HeroClass::Freeze()
620 {
621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if (action != inwind)
622 {
623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
624 80 else {action=freeze; FFCore.setHeroAction(freeze);}
625 // also cancel Hero's attack
626 80 attackclk = 0;
627 80 }
628 80 }
629 33 void HeroClass::unfreeze()
630 {
631
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
33 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
632
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
633 33 }
634
635 2 void HeroClass::Drown(int32_t state)
636 {
637 // Hero should never drown if the ladder is out
638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(ladderx+laddery)
639 return;
640
641 2 drop_liftwpn();
642
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 switch(state)
643 {
644 case 1:
645 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
646 attackclk=0;
647 attack=wNone;
648 attackid=-1;
649 reset_swordcharge();
650 drownclk=64;
651 z=fakez=fall=fakefall=0;
652 break;
653
654
655 default:
656 {
657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
658 2 else {action=drowning; FFCore.setHeroAction(drowning);}
659 2 attackclk=0;
660 2 attack=wNone;
661 2 attackid=-1;
662 2 reset_swordcharge();
663 2 drownclk=64;
664 2 z=fakez=fall=fakefall=0;
665 2 break;
666 }
667 }
668
669 2 }
670
671 15 void HeroClass::finishedmsg()
672 {
673 //these are to cancel out any keys that Hero may
674 //be pressing so he doesn't attack at the end of
675 //a message if he was scrolling through it quickly.
676 15 rAbtn();
677 15 rBbtn();
678 15 unfreeze();
679
680
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
30 if(action == landhold1 ||
681
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 action == landhold2 ||
682
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 action == waterhold1 ||
683
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 action == waterhold2 ||
684
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 action == sidewaterhold1 ||
685 15 action == sidewaterhold2)
686 {
687 holdclk = 1;
688 }
689 15 }
690 void HeroClass::setEaten(int32_t i)
691 {
692 inlikelike=i;
693 }
694 int32_t HeroClass::getEaten()
695 {
696 return inlikelike;
697 }
698 74527 zfix HeroClass::getX()
699 {
700 74527 return x;
701 }
702 60040 zfix HeroClass::getY()
703 {
704 60040 return y;
705 }
706 462886 zfix HeroClass::getZ()
707 {
708 462886 return z;
709 }
710 287675 zfix HeroClass::getFakeZ()
711 {
712 287675 return fakez;
713 }
714 1222 zfix HeroClass::getFall()
715 {
716 1222 return fall;
717 }
718 zfix HeroClass::getFakeFall()
719 {
720 return fakefall;
721 }
722 zfix HeroClass::getXOfs()
723 {
724 return xofs;
725 }
726 zfix HeroClass::getYOfs()
727 {
728 return yofs;
729 }
730 void HeroClass::setXOfs(int32_t newxofs)
731 {
732 xofs=newxofs;
733 }
734 void HeroClass::setYOfs(int32_t newyofs)
735 {
736 yofs=newyofs;
737 }
738 int32_t HeroClass::getHXOfs()
739 {
740 return hxofs;
741 }
742 int32_t HeroClass::getHYOfs()
743 {
744 return hyofs;
745 }
746 int32_t HeroClass::getHXSz()
747 {
748 return hxsz;
749 }
750 int32_t HeroClass::getHYSz()
751 {
752 return hysz;
753 }
754 1792 zfix HeroClass::getClimbCoverX()
755 {
756 1792 return climb_cover_x;
757 }
758 1792 zfix HeroClass::getClimbCoverY()
759 {
760 1792 return climb_cover_y;
761 }
762 int32_t HeroClass::getLadderX()
763 {
764 return ladderx;
765 }
766 int32_t HeroClass::getLadderY()
767 {
768 return laddery;
769 }
770
771 4 void HeroClass::setX(int32_t new_x)
772 {
773 4 zfix dx=new_x-x;
774
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(Lwpns.idFirst(wHookshot)>-1)
775 {
776 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
777 hs_startx+=(int32_t)dx;
778 }
779
780
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(Lwpns.idFirst(wHSHandle)>-1)
781 {
782 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
783 }
784
785
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(chainlinks.Count()>0)
786 {
787 for(int32_t j=0; j<chainlinks.Count(); j++)
788 {
789 chainlinks.spr(j)->x+=dx;
790 }
791 }
792
793 4 x=new_x;
794
795 // A kludge
796
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
4 if(!diagonalMovement && dir<=down)
797 2 is_on_conveyor=true;
798 4 }
799
800 4 void HeroClass::setY(int32_t new_y)
801 {
802 4 zfix dy=new_y-y;
803
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(Lwpns.idFirst(wHookshot)>-1)
804 {
805 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
806 hs_starty+=(int32_t)dy;
807 }
808
809
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(Lwpns.idFirst(wHSHandle)>-1)
810 {
811 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
812 }
813
814
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(chainlinks.Count()>0)
815 {
816 for(int32_t j=0; j<chainlinks.Count(); j++)
817 {
818 chainlinks.spr(j)->y+=dy;
819 }
820 }
821
822 4 y=new_y;
823
824 // A kludge
825
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
4 if(!diagonalMovement && dir>=left)
826 is_on_conveyor=true;
827 4 }
828
829 void HeroClass::setZ(int32_t new_z)
830 {
831 if(isSideViewHero())
832 return;
833
834 if(z==0 && new_z > 0)
835 {
836 switch(action)
837 {
838 case swimming:
839 {
840 diveclk=0;
841 action=walking; FFCore.setHeroAction(walking);
842 break;
843 }
844
845 case waterhold1:
846 {
847 action=landhold1; FFCore.setHeroAction(landhold1);
848 break;
849 }
850
851 case waterhold2:
852 {
853 action=landhold2; FFCore.setHeroAction(landhold2);
854 break;
855 }
856
857 default:
858 if(charging) //!DIMITODO: Let Hero jump while charging sword
859 {
860 reset_swordcharge();
861 attackclk=0;
862 }
863
864 break;
865 }
866 }
867
868 z=(new_z>0 ? new_z : 0);
869 }
870
871 void HeroClass::setFakeZ(int32_t new_z)
872 {
873 if(isSideViewHero())
874 return;
875
876 if(fakez==0 && new_z > 0)
877 {
878 switch(action)
879 {
880 case swimming:
881 {
882 diveclk=0;
883 action=walking; FFCore.setHeroAction(walking);
884 break;
885 }
886
887 case waterhold1:
888 {
889 action=landhold1; FFCore.setHeroAction(landhold1);
890 break;
891 }
892
893 case waterhold2:
894 {
895 action=landhold2; FFCore.setHeroAction(landhold2);
896 break;
897 }
898
899 default:
900 if(charging) //!DIMITODO: Let Hero jump while charging sword
901 {
902 reset_swordcharge();
903 attackclk=0;
904 }
905
906 break;
907 }
908 }
909
910 fakez=(new_z>0 ? new_z : 0);
911 }
912
913 88 void HeroClass::setXfix(zfix new_x)
914 {
915 //Z_scripterrlog("setxdbl: %f\n",new_x);
916 88 zfix dx=new_x-x;
917
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(Lwpns.idFirst(wHookshot)>-1)
918 {
919 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
920 hs_startx+=(int32_t)dx;
921 }
922
923
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(Lwpns.idFirst(wHSHandle)>-1)
924 {
925 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
926 }
927
928
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(chainlinks.Count()>0)
929 {
930 for(int32_t j=0; j<chainlinks.Count(); j++)
931 {
932 chainlinks.spr(j)->x+=dx;
933 }
934 }
935
936 88 x=new_x;
937
938 // A kludge
939
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
88 if(!diagonalMovement && dir<=down)
940 is_on_conveyor=true;
941 88 }
942
943 58 void HeroClass::setYfix(zfix new_y)
944 {
945 58 zfix dy=new_y-y;
946
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Lwpns.idFirst(wHookshot)>-1)
947 {
948 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
949 hs_starty+=(int32_t)dy;
950 }
951
952
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(Lwpns.idFirst(wHSHandle)>-1)
953 {
954 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
955 }
956
957
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(chainlinks.Count()>0)
958 {
959 for(int32_t j=0; j<chainlinks.Count(); j++)
960 {
961 chainlinks.spr(j)->y+=dy;
962 }
963 }
964
965 58 y=new_y;
966
967 // A kludge
968
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if(!diagonalMovement && dir>=left)
969 is_on_conveyor=true;
970 58 }
971
972 void HeroClass::setZfix(zfix new_z)
973 {
974 if(isSideViewHero())
975 return;
976
977 if(z==0 && new_z > 0)
978 {
979 switch(action)
980 {
981 case swimming:
982 {
983 diveclk=0;
984 action=walking; FFCore.setHeroAction(walking);
985 break;
986 }
987
988 case waterhold1:
989 {
990 action=landhold1; FFCore.setHeroAction(landhold1);
991 break;
992 }
993
994 case waterhold2:
995 {
996 action=landhold2; FFCore.setHeroAction(landhold2);
997 break;
998 }
999
1000 default:
1001 if(charging) //!DIMITODO: Let Hero jump while charging sword
1002 {
1003 reset_swordcharge();
1004 attackclk=0;
1005 }
1006
1007 break;
1008 }
1009 }
1010
1011 z=(new_z>0 ? new_z : zfix(0));
1012 }
1013
1014 void HeroClass::setFakeZfix(zfix new_z)
1015 {
1016 if(isSideViewHero())
1017 return;
1018
1019 if(fakez==0 && new_z > 0)
1020 {
1021 switch(action)
1022 {
1023 case swimming:
1024 {
1025 diveclk=0;
1026 action=walking; FFCore.setHeroAction(walking);
1027 break;
1028 }
1029
1030 case waterhold1:
1031 {
1032 action=landhold1; FFCore.setHeroAction(landhold1);
1033 break;
1034 }
1035
1036 case waterhold2:
1037 {
1038 action=landhold2; FFCore.setHeroAction(landhold2);
1039 break;
1040 }
1041
1042 default:
1043 if(charging) //!DIMITODO: Let Hero jump while charging sword
1044 {
1045 reset_swordcharge();
1046 attackclk=0;
1047 }
1048
1049 break;
1050 }
1051 }
1052
1053 fakez=(new_z>0 ? new_z : zfix(0));
1054 }
1055
1056 54 void HeroClass::setFall(zfix new_fall)
1057 {
1058 54 fall=new_fall;
1059 54 jumping=-1;
1060 54 }
1061 void HeroClass::setFakeFall(zfix new_fall)
1062 {
1063 fakefall=new_fall;
1064 jumping=-1;
1065 }
1066 void HeroClass::setClimbCoverX(int32_t new_x)
1067 {
1068 climb_cover_x=new_x;
1069 }
1070 void HeroClass::setClimbCoverY(int32_t new_y)
1071 {
1072 climb_cover_y=new_y;
1073 }
1074 275 int32_t HeroClass::getLStep()
1075 {
1076 275 return lstep;
1077 }
1078 int32_t HeroClass::getCharging()
1079 {
1080 return charging;
1081 }
1082 435 bool HeroClass::isCharged()
1083 {
1084 435 return spins>0;
1085 }
1086 int32_t HeroClass::getAttackClk()
1087 {
1088 return attackclk;
1089 }
1090 void HeroClass::setAttackClk(int32_t new_clk)
1091 {
1092 attackclk=new_clk;
1093 }
1094 void HeroClass::setCharging(int32_t new_charging)
1095 {
1096 charging=new_charging;
1097 }
1098 34699488 int32_t HeroClass::getSwordClk()
1099 {
1100 34699488 return swordclk;
1101 }
1102 34571593 int32_t HeroClass::getItemClk()
1103 {
1104 34571593 return itemclk;
1105 }
1106 void HeroClass::setSwordClk(int32_t newclk)
1107 {
1108 swordclk=newclk;
1109 verifyAWpn();
1110 }
1111 void HeroClass::setItemClk(int32_t newclk)
1112 {
1113 itemclk=newclk;
1114 }
1115 2020 zfix HeroClass::getModifiedX()
1116 {
1117 2020 zfix tempx=x;
1118
1119
4/4
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 1280 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 131 times.
2020 if(screenscrolling&&(dir==left))
1120 {
1121 131 tempx=tempx+256;
1122 131 }
1123
1124 2020 return tempx;
1125 }
1126
1127 2020 zfix HeroClass::getModifiedY()
1128 {
1129 2020 zfix tempy=y;
1130
1131
4/4
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 1280 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 550 times.
2020 if(screenscrolling&&(dir==up))
1132 {
1133 190 tempy=tempy+176;
1134 190 }
1135
1136 2020 return tempy;
1137 }
1138
1139 34 int32_t HeroClass::getDir()
1140 {
1141 34 return dir;
1142 }
1143 41 void HeroClass::setDir(int32_t newdir)
1144 {
1145 41 dir=newdir;
1146 41 reset_hookshot();
1147 41 }
1148 int32_t HeroClass::getHitDir()
1149 {
1150 return hitdir;
1151 }
1152 void HeroClass::setHitDir(int32_t newdir)
1153 {
1154 hitdir = newdir;
1155 }
1156 int32_t HeroClass::getClk()
1157 {
1158 return clk;
1159 }
1160 int32_t HeroClass::getPushing()
1161 {
1162 return pushing;
1163 }
1164 152 void HeroClass::Catch()
1165 {
1166
5/6
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121 times.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 57 times.
152 if(!inwallm && (action==none || action==walking))
1167 {
1168 95 SetAttack();
1169 95 attackclk=0;
1170 95 attack=wCatching;
1171 95 }
1172 152 }
1173
1174 62424 bool HeroClass::getClock()
1175 {
1176 62424 return superman;
1177 }
1178 3 void HeroClass::setClock(bool state)
1179 {
1180 3 superman=state;
1181 3 }
1182 529650 int32_t HeroClass::getAction() // Used by ZScript
1183 {
1184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529650 times.
529650 if(spins > 0)
1185 return isspinning;
1186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529650 times.
529650 else if(charging > 0)
1187 return ischarging;
1188
1/2
✓ Branch 0 taken 529650 times.
✗ Branch 1 not taken.
529650 else if(diveclk > 0)
1189 return isdiving;
1190 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1191
1192 529650 return action;
1193 529650 }
1194
1195 121269 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1196 {
1197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121269 times.
121269 if(spins > 0)
1198 return isspinning;
1199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121269 times.
121269 else if(charging > 0)
1200 return ischarging;
1201
1/2
✓ Branch 0 taken 121269 times.
✗ Branch 1 not taken.
121269 else if(diveclk > 0)
1202 return isdiving;
1203 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1204
1205 121269 return -1;
1206 121269 }
1207
1208 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1209 {
1210 if(new_action==dying || new_action==won || new_action==scrolling ||
1211 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1212 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1213 return; // Can't use these actions.
1214
1215 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1216 return;
1217
1218 if(new_action==rafting)
1219 {
1220 if(get_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING)) return;
1221 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1222 return;
1223 }
1224
1225
1226 if(magicitem>-1 && itemsbuf[magicitem].family==itype_faroreswind)
1227 {
1228 // Using Farore's Wind
1229 if(magiccastclk<96)
1230 {
1231 // Not cast yet; cancel it
1232 magicitem=-1;
1233 magiccastclk=0;
1234 }
1235 else
1236 // Already activated; don't do anything
1237 return;
1238 }
1239
1240 if(action==inwind) // Remove from whirlwind
1241 {
1242 xofs=0;
1243 whirlwind=0;
1244 lstep=0;
1245 if ( dontdraw < 2 ) { dontdraw=0; }
1246 }
1247 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1248 {
1249 sprite* wind=0;
1250 bool foundWind=false;
1251 for(int32_t i=0; i<Ewpns.Count(); i++)
1252 {
1253 wind=Ewpns.spr(i);
1254 if(wind->id==ewWind && wind->misc==999)
1255 {
1256 foundWind=true;
1257 break;
1258 }
1259 }
1260
1261 if(foundWind)
1262 {
1263 xofs=0;
1264 if ( dontdraw < 2 ) { dontdraw=false; }
1265 wind->misc=-1;
1266 x=wind->x;
1267 y=wind->y;
1268 }
1269 }
1270
1271 //Unless compat rule is on, reset hopping clocks when writing action!
1272 if(action == hopping && !get_bit(quest_rules,qr_NO_OVERWRITING_HOPPING))
1273 {
1274 hopclk = 0;
1275 hopdir = -1;
1276 }
1277
1278 if(new_action != attacking && new_action != sideswimattacking)
1279 {
1280 attackclk=0;
1281
1282 if(attack==wHookshot)
1283 reset_hookshot();
1284 }
1285 if(new_action != isspinning && new_action != sideswimisspinning)
1286 {
1287 charging = 0;
1288 spins = 0;
1289 }
1290
1291 if(action == falling && new_action != falling)
1292 {
1293 fallclk = 0; //Stop falling;
1294 }
1295
1296 if (action == rafting && new_action != rafting)
1297 {
1298 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1299 raftwarpy = y;
1300 }
1301
1302 switch(new_action)
1303 {
1304 case isspinning:
1305 case sideswimisspinning:
1306 if(attack==wSword)
1307 {
1308 attackclk = SWORDCHARGEFRAME+1;
1309 charging = 0;
1310
1311 if(spins==0)
1312 spins = 5;
1313 }
1314 return;
1315
1316 case isdiving:
1317 if(action==swimming && diveclk==0)
1318 {
1319 int32_t flippers_id = current_item_id(itype_flippers);
1320 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1321 }
1322 return;
1323
1324 case drowning:
1325 case sidedrowning:
1326 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1327 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1328 if(!drownclk)
1329 Drown();
1330
1331 break;
1332
1333 case lavadrowning:
1334 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1335 if(!drownclk)
1336 Drown(1);
1337
1338 break;
1339
1340 case falling:
1341 if(!fallclk)
1342 {
1343 //If there is a pit under Hero, use it's combo.
1344 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1345 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1346 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1347 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1348 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1349 //Else, use a null value; triggers default pit values
1350 else fallCombo = 0;
1351 fallclk = PITFALL_FALL_FRAMES;
1352 }
1353 break;
1354
1355 case gothit:
1356 case swimhit:
1357 case sideswimhit:
1358 if(!hclk)
1359 hclk=48;
1360
1361 break;
1362
1363 case landhold1:
1364 case landhold2:
1365 case waterhold1:
1366 case waterhold2:
1367 case sidewaterhold1:
1368 case sidewaterhold2:
1369 if(!holdclk)
1370 holdclk=130;
1371
1372 attack=none;
1373 break;
1374
1375 case attacking:
1376 case sideswimattacking:
1377 attack=none;
1378 break;
1379
1380 default:
1381 break;
1382 }
1383
1384 action=new_action; FFCore.setHeroAction(new_action);
1385 }
1386
1387 void HeroClass::setHeldItem(int32_t newitem)
1388 {
1389 holditem=newitem;
1390 }
1391 int32_t HeroClass::getHeldItem()
1392 {
1393 return holditem;
1394 }
1395 78618 bool HeroClass::isDiving()
1396 {
1397 78618 int32_t flippers_id = current_item_id(itype_flippers);
1398
2/2
✓ Branch 0 taken 76575 times.
✓ Branch 1 taken 2043 times.
78618 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1399 }
1400 171204 bool HeroClass::isSwimming()
1401 {
1402
4/6
✓ Branch 0 taken 169623 times.
✓ Branch 1 taken 1581 times.
✓ Branch 2 taken 169623 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 169623 times.
✗ Branch 5 not taken.
340827 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1403
2/4
✓ Branch 0 taken 169623 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 169623 times.
169623 (action==waterhold1)||(action==waterhold2)||
1404 169623 (hopclk==0xFF));
1405 }
1406
1407 58 void HeroClass::setDontDraw(byte new_dontdraw)
1408 {
1409 58 dontdraw=new_dontdraw;
1410 58 }
1411
1412 4354 byte HeroClass::getDontDraw()
1413 {
1414 4354 return dontdraw;
1415 }
1416
1417 void HeroClass::setHClk(int32_t newhclk)
1418 {
1419 hclk=newhclk;
1420 }
1421
1422 int32_t HeroClass::getHClk()
1423 {
1424 return hclk;
1425 }
1426
1427 22545 int32_t HeroClass::getSpecialCave()
1428 {
1429 22545 return specialcave; // used only by maps.cpp
1430 }
1431
1432 31 void HeroClass::init()
1433 {
1434 31 usecounts.clear();
1435 31 scale = 0;
1436 31 rotation = 0;
1437 31 do_animation = 1;
1438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(lift_wpn)
1439 {
1440 delete lift_wpn;
1441 lift_wpn = nullptr;
1442 }
1443 31 liftclk = 0;
1444 31 tliftclk = 0;
1445 31 liftheight = 0;
1446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1447 31 hookshot_used=false;
1448 31 hookshot_frozen=false;
1449 31 onpassivedmg=false;
1450 31 dir = up;
1451 31 damageovertimeclk = 0;
1452 31 newconveyorclk = 0;
1453 31 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1454
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 31 times.
248 for(auto q = 0; q < 7; ++q)
1455 217 hooked_undercombos[q] = -1;
1456 31 shiftdir = -1;
1457 31 sideswimdir = right;
1458 31 holddir = -1;
1459 31 landswim = 0;
1460 31 sdir = up;
1461 31 ilswim=true;
1462 31 walkable=false;
1463 31 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1464 31 warp_sound = 0;
1465 31 subscr_speed = zinit.subscrSpeed;
1466 31 steprate = zinit.heroStep;
1467 31 is_warping = false;
1468 31 can_mirror_portal = true;
1469 31 coyotetime = 0;
1470
1471 31 hammer_swim_up_offset = hammeroffsets[0];
1472 31 hammer_swim_down_offset = hammeroffsets[1];
1473 31 hammer_swim_left_offset = hammeroffsets[2];
1474 31 hammer_swim_right_offset = hammeroffsets[3];
1475
1476 31 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1477
1478
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 27 times.
31 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
1479 {
1480 4 x=tmpscr->warpreturnx[0];
1481 4 y=tmpscr->warpreturny[0];
1482 4 }
1483 else
1484 {
1485 27 x=tmpscr->warparrivalx;
1486 27 y=tmpscr->warparrivaly;
1487 }
1488
1489 31 z=fakez=fall=fakefall=0;
1490 31 hzsz = 12; // So that flying peahats can still hit him.
1491
1492
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 15 times.
31 if(x==0) dir=right;
1493
1494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(x==240) dir=left;
1495
1496
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 15 times.
31 if(y==0) dir=down;
1497
1498
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 30 times.
31 if(y==160) dir=up;
1499
1500 31 lstep=0;
1501 31 skipstep=0;
1502 31 autostep=false;
1503 31 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1504 31 attack=wNone;
1505 31 attackid=-1;
1506 31 action=none; FFCore.setHeroAction(none); tempaction=none;
1507 31 xofs=0;
1508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1509 31 cs=6;
1510 31 pushing=fairyclk=0;
1511 31 id=0;
1512 31 inlikelike=0;
1513 31 superman=inwallm=false;
1514 31 scriptcoldet=1;
1515 31 blowcnt=whirlwind=specialcave=0;
1516 31 hopclk=diveclk=fallclk=0;
1517 31 fallCombo = 0;
1518 31 pit_pulldir = -1;
1519 31 hopdir=-1;
1520 31 conveyor_flags=0;
1521 31 drunkclk=0;
1522 31 lstunclock = 0;
1523 31 is_conveyor_stunned=0;
1524 31 drawstyle=3;
1525 31 ffwarp = false;
1526 31 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1527 31 stepnext=stepsecret=-1;
1528 31 ffpit = false;
1529 31 respawn_x=x;
1530 31 respawn_y=y;
1531 31 respawn_dmap=currdmap;
1532 31 respawn_scr=currscr;
1533 31 falling_oldy = y;
1534 31 magiccastclk=0;
1535 31 magicitem = nayruitem = -1;
1536 31 last_lens_id = 0; //Should be -1 (-Z)
1537 31 last_savepoint_id = 0;
1538 31 misc_internal_hero_flags = 0;
1539 31 last_cane_of_byrna_item_id = -1;
1540 31 on_sideview_ladder = false;
1541 31 switchblock_z = 0;
1542 31 switchblock_offset = false;
1543 31 extra_jump_count = 0;
1544 31 hoverflags = 0;
1545 31 lbunnyclock = 0;
1546
1547
2/2
✓ Branch 0 taken 992 times.
✓ Branch 1 taken 31 times.
1023 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1548
1549 31 setBigHitbox(get_bit(quest_rules, qr_LTTPCOLLISION));
1550 31 diagonalMovement=(get_bit(quest_rules,qr_LTTPWALK));
1551
1552 31 shield_active = false;
1553 31 shield_forcedir = -1;
1554 31 active_shield_id = -1;
1555
1556 //2.6
1557 31 preventsubscreenfalling = false; //-Z
1558 31 walkspeed = 0; //not used, yet. -Z
1559
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 31 times.
527 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1560
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 31 times.
527 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1561
2/2
✓ Branch 0 taken 4526 times.
✓ Branch 1 taken 31 times.
4557 for ( int32_t q = 0; q < wMax; q++ )
1562 {
1563 4526 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1564 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1565 4526 }
1566 //Run script!
1567
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
31 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1568 {
1569 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT, SCRIPT_PLAYER_INIT);
1570 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT);
1571 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1572 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1573 //are properly set by the engine.
1574 }
1575 31 FFCore.nostepforward = 0;
1576 31 }
1577
1578 91956 void HeroClass::draw_under(BITMAP* dest)
1579 {
1580 91956 int32_t c_raft=current_item_id(itype_raft);
1581 91956 int32_t c_ladder=current_item_id(itype_ladder);
1582
1583
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 91956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
91956 if(action==rafting && c_raft >-1)
1584 {
1585 if(((dir==left) || (dir==right)) && (get_bit(quest_rules,qr_RLFIX)))
1586 {
1587 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1588 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1589 }
1590 else
1591 {
1592 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1593 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1594 }
1595 }
1596
1597
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 91956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
91956 if(ladderx+laddery && c_ladder >-1)
1598 {
1599 if((ladderdir>=left) && (get_bit(quest_rules,qr_RLFIX)))
1600 {
1601 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1602 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1603 }
1604 else
1605 {
1606 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1607 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1608 }
1609 }
1610 91956 }
1611
1612 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1613 {
1614 int32_t tempy=yofs;
1615 yofs+=8;
1616 shadowtile = wpnsbuf[spr_shadow].tile;
1617 sprite::drawshadow(dest,translucent);
1618 yofs=tempy;
1619 }
1620
1621 // The Stone of Agony reacts to these flags.
1622 bool HeroClass::agonyflag(int32_t flag)
1623 {
1624 switch(flag)
1625 {
1626 case mfWHISTLE:
1627 case mfBCANDLE:
1628 case mfARROW:
1629 case mfBOMB:
1630 case mfSBOMB:
1631 case mfBRANG:
1632 case mfMBRANG:
1633 case mfFBRANG:
1634 case mfSARROW:
1635 case mfGARROW:
1636 case mfRCANDLE:
1637 case mfWANDFIRE:
1638 case mfDINSFIRE:
1639 case mfWANDMAGIC:
1640 case mfREFMAGIC:
1641 case mfREFFIREBALL:
1642 case mfSWORD:
1643 case mfWSWORD:
1644 case mfMSWORD:
1645 case mfXSWORD:
1646 case mfSWORDBEAM:
1647 case mfWSWORDBEAM:
1648 case mfMSWORDBEAM:
1649 case mfXSWORDBEAM:
1650 case mfHOOKSHOT:
1651 case mfWAND:
1652 case mfHAMMER:
1653 case mfSTRIKE:
1654 return true;
1655 }
1656
1657 return false;
1658 }
1659
1660
1661 // Find the attack power of the current melee weapon.
1662 // The Whimsical Ring is applied on a target-by-target basis.
1663 4545 int32_t HeroClass::weaponattackpower(int32_t itid)
1664 {
1665
1/2
✓ Branch 0 taken 4545 times.
✗ Branch 1 not taken.
4545 if(itid < 0)
1666 {
1667 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1668 : attack==wWand ? itype_wand
1669 : attack==wHammer ? itype_hammer
1670 : itype_sword);
1671 }
1672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4545 times.
4545 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1673
1674 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1675
1/6
✓ Branch 0 taken 4545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4545 power *= (spins>0 ? itemsbuf[current_item_id(attack==wHammer ? itype_quakescroll : (spins>5 || current_item_id(itype_spinscroll) < 0) ? itype_spinscroll2 : itype_spinscroll)].power : 1);
1676 4545 return power;
1677 }
1678
1679 #define NET_CLK_TOTAL 24
1680 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1681 // Must only be called once per frame!
1682 void HeroClass::positionNet(weapon *w, int32_t itemid)
1683 {
1684 itemid = vbound(itemid, 0, MAXITEMS-1);
1685 int32_t t = w->o_tile,
1686 wx = 1, wy = 1;
1687
1688 //Invert positioning clock if right-handed animation
1689 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1690 if(clock >= NET_CLK_TOTAL)
1691 w->dead = 0;
1692 int32_t tiledir = dir;
1693 switch(dir)
1694 {
1695 case up:
1696 {
1697 if(clock < NET_DIR_INC) tiledir = l_up;
1698 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1699 break;
1700 }
1701 case down:
1702 {
1703 if(clock < NET_DIR_INC) tiledir = r_down;
1704 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1705 break;
1706 }
1707 case left:
1708 {
1709 if(clock < NET_DIR_INC) tiledir = l_down;
1710 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1711 break;
1712 }
1713 case right:
1714 {
1715 if(clock < NET_DIR_INC) tiledir = r_up;
1716 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1717 break;
1718 }
1719 }
1720 int32_t offs = 0;
1721 if(tiledir > right)
1722 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1723 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1724 //One of 8 positions
1725 switch(tiledir)
1726 {
1727 case up:
1728 {
1729 wx = 6*offs;
1730 wy = -14;
1731 break;
1732 }
1733 case r_up:
1734 {
1735 wx = (offs ? 10 : 14);
1736 wy = (offs ? -12 : -10);
1737 break;
1738 }
1739 case right:
1740 {
1741 wx = 14;
1742 wy = 6*offs;
1743 break;
1744 }
1745 case r_down:
1746 {
1747 wx = (offs ? 14 : 10);
1748 wy = (offs ? 10 : 12);
1749 break;
1750 }
1751 case down:
1752 {
1753 wx = -6*offs;
1754 wy = 14;
1755 break;
1756 }
1757 case l_down:
1758 {
1759 wx = (offs ? -10 : -14);
1760 wy = (offs ? 12 : 10);
1761 break;
1762 }
1763 case left:
1764 {
1765 wx = -14;
1766 wy = -6*offs;
1767 break;
1768 }
1769 case l_up:
1770 {
1771 wx = (offs ? -14 : -10);
1772 wy = (offs ? -10 : -12);
1773 break;
1774 }
1775 }
1776
1777 w->x = x+wx;
1778 w->y = y+wy-(54-(yofs))-fakez;
1779 w->z = (z+zofs);
1780 w->fakez = fakez;
1781 w->tile = t+tiledir;
1782 w->power = 0;
1783 w->dir = dir;
1784 w->doAutoRotate(true);
1785 }
1786 4370 void HeroClass::positionSword(weapon *w, int32_t itemid)
1787 {
1788 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1789 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1790 4370 itemid=vbound(itemid, 0, MAXITEMS-1);
1791 // Place a sword weapon at the right spot.
1792 4370 int32_t wy=1;
1793 4370 int32_t wx=1;
1794 4370 int32_t f=0,t,cs2;
1795
1796 4370 t = w->o_tile;
1797 4370 cs2 = w->o_cset;
1798 4370 slashxofs=0;
1799 4370 slashyofs=0;
1800
1801
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 657 times.
✓ Branch 2 taken 632 times.
✓ Branch 3 taken 1228 times.
✓ Branch 4 taken 1853 times.
4370 switch(dir)
1802 {
1803 case up:
1804 657 wx=-1;
1805 657 wy=-12;
1806
1807
5/8
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 632 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 25 times.
657 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1808 {
1809
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 9 times.
25 if(attackclk>10) //extended stab
1810 {
1811 9 slashyofs-=3;
1812 9 wy-=2;
1813 9 }
1814
1815
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
25 if(attackclk>=14) //retracting stab
1816 {
1817 6 slashyofs+=3;
1818 6 wy+=2;
1819 6 }
1820 25 }
1821 else
1822 {
1823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 632 times.
632 if(attackclk==SWORDCHARGEFRAME)
1824 {
1825 wy+=4;
1826 }
1827
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 570 times.
632 else if(attackclk==13)
1828 {
1829 62 wy+=4;
1830 62 }
1831
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 62 times.
570 else if(attackclk==14)
1832 {
1833 62 wy+=8;
1834 62 }
1835 }
1836
1837 657 break;
1838
1839 case down:
1840 632 f=get_bit(quest_rules,qr_SWORDWANDFLIPFIX)?3:2;
1841 632 wy=11;
1842
1843
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
632 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1844 {
1845 if(attackclk>10) //extended stab
1846 {
1847 slashyofs+=3;
1848 wy+=2;
1849 }
1850
1851 if(attackclk>=14) //retracting stab
1852 {
1853 slashyofs-=3;
1854 wy-=2;
1855 }
1856 }
1857 else
1858 {
1859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 632 times.
632 if(attackclk==SWORDCHARGEFRAME)
1860 {
1861 wy-=2;
1862 }
1863
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 568 times.
632 else if(attackclk==13)
1864 {
1865 64 wy-=4;
1866 64 }
1867
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 64 times.
568 else if(attackclk==14)
1868 {
1869 64 wy-=8;
1870 64 }
1871 }
1872
1873 632 break;
1874
1875 case left:
1876 1228 f=1;
1877 1228 wx=-11;
1878 1228 ++t;
1879
1880
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1228 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1881 {
1882 if(attackclk>10) //extended stab
1883 {
1884 slashxofs-=4;
1885 wx-=7;
1886 }
1887
1888 if(attackclk>=14) //retracting stab
1889 {
1890 slashxofs+=3;
1891 wx+=7;
1892 }
1893 }
1894 else
1895 {
1896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(attackclk==SWORDCHARGEFRAME)
1897 {
1898 wx+=2;
1899 }
1900
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 1106 times.
1228 else if(attackclk==13)
1901 {
1902 122 wx+=4;
1903 122 }
1904
2/2
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 122 times.
1106 else if(attackclk==14)
1905 {
1906 122 wx+=8;
1907 122 }
1908 }
1909
1910 1228 break;
1911
1912 case right:
1913 1853 wx=11;
1914 1853 ++t;
1915
1916
5/8
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 1787 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 66 times.
✗ Branch 7 not taken.
1853 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1917 {
1918
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 20 times.
66 if(attackclk>10) //extended stab
1919 {
1920 20 slashxofs+=4;
1921 20 wx+=7;
1922 20 }
1923
1924
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 5 times.
66 if(attackclk>=14) //retracting stab
1925 {
1926 5 slashxofs-=3;
1927 5 wx-=7;
1928 5 }
1929 66 }
1930 else
1931 {
1932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1787 times.
1787 if(attackclk==SWORDCHARGEFRAME)
1933 {
1934 wx-=2;
1935 }
1936
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 1608 times.
1787 else if(attackclk==13)
1937 {
1938 179 wx-=4;
1939 179 }
1940
2/2
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 179 times.
1608 else if(attackclk==14)
1941 {
1942 179 wx-=8;
1943 179 }
1944 }
1945
1946 1853 break;
1947 }
1948
1949
5/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 62 times.
4370 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
1950 {
1951 62 int32_t wpn2=itemsbuf[itemid].wpn2;
1952 62 wpn2=vbound(wpn2, 0, MAXWPNS);
1953
1954 //slashing tiles
1955
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
62 switch(dir)
1956 {
1957 case up:
1958 16 wx=15;
1959 16 wy=-3;
1960 16 ++t;
1961 16 f=0; //starts pointing right
1962
1963
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9 times.
16 if(attackclk>=7)
1964 {
1965 9 wy-=9;
1966 9 wx-=3;
1967 9 t = wpnsbuf[wpn2].tile;
1968 9 cs2 = wpnsbuf[wpn2].csets&15;
1969 9 f=0;
1970 9 }
1971
1972 16 break;
1973
1974 case down:
1975 wx=-13;
1976 wy=-1;
1977 ++t;
1978 f=1; //starts pointing left
1979
1980 if(attackclk>=7)
1981 {
1982 wy+=15;
1983 wx+=2;
1984 t = wpnsbuf[wpn2].tile;
1985 cs2 = wpnsbuf[wpn2].csets&15;
1986 ++t;
1987 f=0;
1988 }
1989
1990 break;
1991
1992 case left:
1993 wx=3;
1994 wy=-15;
1995 --t;
1996 f=0; //starts pointing up
1997
1998 if(attackclk>=7)
1999 {
2000 wx-=15;
2001 wy+=3;
2002 slashxofs-=1;
2003 t = wpnsbuf[wpn2].tile;
2004 cs2 = wpnsbuf[wpn2].csets&15;
2005 t+=2;
2006 f=0;
2007 }
2008
2009 break;
2010
2011 case right:
2012 46 --t;
2013
2014
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
46 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2015 {
2016 wx=1;
2017 wy=13;
2018 f=2;
2019 }
2020 else
2021 {
2022 46 wx=3;
2023 46 wy=-15;
2024 46 f=0;
2025 }
2026
2027
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 26 times.
46 if(attackclk>=7)
2028 {
2029 26 wx+=15;
2030 26 slashxofs+=1;
2031 26 t = wpnsbuf[wpn2].tile;
2032 26 cs2 = wpnsbuf[wpn2].csets&15;
2033
2034
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
26 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2035 {
2036 wx-=1;
2037 wy-=2;
2038 }
2039 else
2040 {
2041 26 t+=3;
2042 26 f=0;
2043 26 wy+=3;
2044 }
2045 26 }
2046
2047 46 break;
2048 }
2049 62 }
2050
2051 4370 int32_t itemid2 = current_item_id(itype_chargering);
2052
2053
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4370 times.
✓ Branch 2 taken 4370 times.
✗ Branch 3 not taken.
4370 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2054 {
2055 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2056 }
2057
2058 /*if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2059 {
2060 wy+=2;
2061 }*/
2062 4370 w->x = x+wx;
2063 4370 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2064 4370 w->z = (z+zofs);
2065 4370 w->tile = t;
2066 4370 w->flip = f;
2067 4370 w->power = weaponattackpower(itemid);
2068 4370 w->dir = dir;
2069 4370 w->doAutoRotate(true);
2070 4370 }
2071
2072 93748 void HeroClass::draw(BITMAP* dest)
2073 {
2074 /*{
2075 char buf[36];
2076 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2077 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2078 }*/
2079 int32_t oxofs, oyofs;
2080 93748 bool shieldModify = false;
2081
2/2
✓ Branch 0 taken 92626 times.
✓ Branch 1 taken 1122 times.
93748 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2082
2083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93748 times.
93748 if(action==dying)
2084 {
2085 if(!invisible)
2086 {
2087 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2088 sprite::draw(dest);
2089 }
2090 return;
2091 }
2092
2093 93748 bool useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2094
2095 93748 oxofs=xofs;
2096 93748 oyofs=yofs;
2097
2098
2/2
✓ Branch 0 taken 1923 times.
✓ Branch 1 taken 91825 times.
93748 if(!invisible)
2099
6/6
✓ Branch 0 taken 76413 times.
✓ Branch 1 taken 15412 times.
✓ Branch 2 taken 49923 times.
✓ Branch 3 taken 26490 times.
✓ Branch 4 taken 1139 times.
✓ Branch 5 taken 48784 times.
91825 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2100
2101 // Stone of Agony
2102 93748 bool agony=false;
2103 93748 int32_t agonyid = current_item_id(itype_agony);
2104
2105
2/2
✓ Branch 0 taken 1923 times.
✓ Branch 1 taken 91825 times.
93748 if(invisible)
2106 1923 goto attack;
2107
2108
1/2
✓ Branch 0 taken 91825 times.
✗ Branch 1 not taken.
91825 if(agonyid>-1)
2109 {
2110 int32_t power=itemsbuf[agonyid].power;
2111 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2112 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2113 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2114 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2115
2116 for(int32_t x=left; x<right; x+=16)
2117 {
2118 for(int32_t y=top; y<bottom; y+=16)
2119 {
2120 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2121 {
2122 agony=true;
2123 x=right; // Break out of outer loop
2124 break;
2125 }
2126 }
2127 }
2128 }
2129
2130 91825 cs = 6;
2131
1/2
✓ Branch 0 taken 91825 times.
✗ Branch 1 not taken.
91825 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2132
2/2
✓ Branch 0 taken 3772 times.
✓ Branch 1 taken 88053 times.
179878 if(!get_bit(quest_rules,qr_HEROFLICKER))
2133 {
2134
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 87502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
88053 if(superman && getCanFlicker())
2135 {
2136 551 cs += (((~frame)>>1)&3);
2137 551 }
2138
4/6
✓ Branch 0 taken 1405 times.
✓ Branch 1 taken 86097 times.
✓ Branch 2 taken 1405 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1405 times.
87502 else if(hclk&&(NayrusLoveShieldClk<=0) && getCanFlicker())
2139 {
2140 1405 cs += ((hclk>>1)&3);
2141 1405 }
2142 88053 }
2143
2144 attack:
2145
2146
5/6
✓ Branch 0 taken 85193 times.
✓ Branch 1 taken 8555 times.
✓ Branch 2 taken 85098 times.
✓ Branch 3 taken 95 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 85098 times.
93748 if(attackclk || (action==attacking||action==sideswimattacking))
2147 {
2148 /* Spaghetti code constants!
2149 * - Hero.attack contains a weapon type...
2150 * - which must be converted to an itype...
2151 * - which must be converted to an item ID...
2152 * - which is used to acquire a wpn ID! Aack!
2153 */
2154
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8650 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8650 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8650 times.
8650 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2155
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8650 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8650 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2156 8650 itemid=vbound(itemid, 0, MAXITEMS-1);
2157 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2158
7/8
✓ Branch 0 taken 2891 times.
✓ Branch 1 taken 5759 times.
✓ Branch 2 taken 2891 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1772 times.
✓ Branch 5 taken 1119 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1724 times.
8650 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2159 {
2160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5807 times.
5807 if(attack == wBugNet)
2161 {
2162 weapon *w=NULL;
2163 bool found = false;
2164 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2165 {
2166 w = (weapon*)Lwpns.spr(q);
2167 if(w->id == wBugNet)
2168 {
2169 found = true;
2170 break;
2171 }
2172 }
2173 if(!found)
2174 {
2175 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2176
2177 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2178 }
2179 positionNet(w, itemid);
2180 }
2181
6/8
✓ Branch 0 taken 1393 times.
✓ Branch 1 taken 4414 times.
✓ Branch 2 taken 1393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1393 times.
✓ Branch 7 taken 4414 times.
5807 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2182 {
2183 // Create a sword weapon at the right spot.
2184 4414 weapon *w=NULL;
2185 4414 bool found = false;
2186
2187 // Look for pre-existing sword
2188
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 4823 times.
5258 for(int32_t i=0; i<Lwpns.Count(); i++)
2189 {
2190 4823 w = (weapon*)Lwpns.spr(i);
2191
2192
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3979 times.
4823 if(w->id == (attack==wSword ? wSword : wWand))
2193 {
2194 3979 found = true;
2195 3979 break;
2196 }
2197 844 }
2198
2199
2/2
✓ Branch 0 taken 3979 times.
✓ Branch 1 taken 435 times.
4414 if(!found) // Create one if sword nonexistant
2200 {
2201
5/10
✓ Branch 0 taken 435 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 435 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 435 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 435 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 435 times.
✗ Branch 9 not taken.
435 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2202 435 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2203
2204 435 positionSword(w,itemid);
2205
2206 // Stone of Agony
2207
1/2
✓ Branch 0 taken 435 times.
✗ Branch 1 not taken.
435 if(agony)
2208 {
2209 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2210 }
2211 435 }
2212
2213 // These are set by positionSword(), above or in checkstab()
2214 4414 yofs += slashyofs;
2215 4414 xofs += slashxofs;
2216 4414 slashyofs = slashxofs = 0;
2217 4414 }
2218 5807 }
2219
2220 8650 if(attackclk<7
2221
4/4
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 4216 times.
✓ Branch 2 taken 3482 times.
✓ Branch 3 taken 952 times.
8650 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2222
4/6
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 2621 times.
✓ Branch 2 taken 861 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 861 times.
3482 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
861 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2224
2/4
✓ Branch 0 taken 1813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1813 times.
✗ Branch 3 not taken.
1813 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2225
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1813 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1813 times.
1813 || (attack==wHammer && attackclk<=30)
2226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1813 times.
1813 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2227 {
2228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6837 times.
6837 if(!invisible)
2229 {
2230 6837 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2231
2/4
✓ Branch 0 taken 6837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6837 times.
✗ Branch 3 not taken.
6837 if (FIXED_Z3_ANIMATION)
2232 {
2233 if (attackclk >= 2) tile += (extend==2?2:1);
2234 if (attackclk >= 13) tile += (extend==2?2:1);
2235 }
2236
2237
12/18
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 6667 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 128 times.
✓ Branch 9 taken 42 times.
✓ Branch 10 taken 57 times.
✓ Branch 11 taken 71 times.
✓ Branch 12 taken 57 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 57 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
6837 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2238 {
2239 71 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2240
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
71 if (FIXED_Z3_ANIMATION)
2241 {
2242 if (attackclk >= 7) tile += (extend==2?2:1);
2243 if (attackclk >= 11) tile += (extend==2?2:1);
2244 if (attackclk >= 14) tile += (extend==2?2:1);
2245 }
2246 71 }
2247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6837 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6837 if (attack==wBugNet && !get_bit(quest_rules, qr_OLD_BUG_NET))
2248 {
2249 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2250 {
2251 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2252 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2253 }
2254 else
2255 {
2256 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2257 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2258 }
2259 }
2260
2261
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6837 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6837 if((attack==wHammer) && (attackclk<13))
2262 {
2263 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2264 if (FIXED_Z3_ANIMATION)
2265 {
2266 if (attackclk >= 14) tile += (extend==2?2:1);
2267 if (attackclk >= 16) tile += (extend==2?2:1);
2268 }
2269 }
2270
2271
2/2
✓ Branch 0 taken 6667 times.
✓ Branch 1 taken 170 times.
6837 if(useltm)
2272 {
2273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2274 170 }
2275
2276 // Stone of Agony
2277
1/2
✓ Branch 0 taken 6837 times.
✗ Branch 1 not taken.
6837 if(agony)
2278 {
2279 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2280 }
2281
2282 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2283
2284 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2285
5/6
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 6642 times.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 192 times.
6837 if (!(get_bit(quest_rules, qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2286 {
2287 6834 masked_draw(dest);
2288 6834 }
2289
2290 //Prevent flickering -Z
2291
1/2
✓ Branch 0 taken 6837 times.
✗ Branch 1 not taken.
6837 if (!getCanFlicker()) masked_draw(dest);
2292 6837 }
2293
2294
1/2
✓ Branch 0 taken 6837 times.
✗ Branch 1 not taken.
6837 if(attack!=wHammer)
2295 {
2296 6837 xofs=oxofs;
2297 6837 yofs=oyofs;
2298 6837 return;
2299 }
2300 }
2301
2302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1813 times.
1813 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2303 {
2304 int32_t wy=1;
2305 int32_t wx=1;
2306 int32_t f=0,t,cs2;
2307 weapon *w=NULL;
2308 bool found = false;
2309
2310 for(int32_t i=0; i<Lwpns.Count(); i++)
2311 {
2312 w = (weapon*)Lwpns.spr(i);
2313
2314 if(w->id == wHammer)
2315 {
2316 found = true;
2317 break;
2318 }
2319 }
2320
2321 if(!found)
2322 {
2323 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2324 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2325 found = true;
2326 }
2327
2328 t = w->o_tile;
2329 cs2 = w->o_cset;
2330
2331 switch(dir)
2332 {
2333 case up:
2334 wx=-1;
2335 wy=-15;
2336 if (IsSideSwim())wy+=hammer_swim_up_offset;
2337
2338 if(attackclk>=13)
2339 {
2340 wx-=1;
2341 wy+=1;
2342 ++t;
2343 }
2344
2345 if(attackclk>=15)
2346 {
2347 if (IsSideSwim())wy-=hammer_swim_up_offset;
2348 ++t;
2349 }
2350
2351 break;
2352
2353 case down:
2354 wx=3;
2355 wy=-14;
2356 if (IsSideSwim())wy+=hammer_swim_down_offset;
2357 t+=3;
2358
2359 if(attackclk>=13)
2360 {
2361 wy+=16;
2362 ++t;
2363 }
2364
2365 if(attackclk>=15)
2366 {
2367 wx-=1;
2368 wy+=12;
2369 if (IsSideSwim())wy-=hammer_swim_down_offset;
2370 ++t;
2371 }
2372
2373 break;
2374
2375 case left:
2376 wx=0;
2377 wy=-14;
2378 if (IsSideSwim())wy+=hammer_swim_left_offset;
2379 t+=6;
2380 f=1;
2381
2382 if(attackclk>=13)
2383 {
2384 wx-=7;
2385 wy+=8;
2386 ++t;
2387 }
2388
2389 if(attackclk>=15)
2390 {
2391 wx-=8;
2392 wy+=8;
2393 if (IsSideSwim())wy-=hammer_swim_left_offset;
2394 ++t;
2395 }
2396
2397 break;
2398
2399 case right:
2400 wx=0;
2401 wy=-14;
2402 if (IsSideSwim())wy+=hammer_swim_right_offset;
2403 t+=6;
2404
2405 if(attackclk>=13)
2406 {
2407 wx+=7;
2408 wy+=8;
2409 ++t;
2410 }
2411
2412 if(attackclk>=15)
2413 {
2414 wx+=8;
2415 wy+=8;
2416 if (IsSideSwim())wy-=hammer_swim_right_offset;
2417 ++t;
2418 }
2419
2420 break;
2421 }
2422
2423 if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2424 {
2425 wy+=2;
2426 }
2427
2428 // Stone of Agony
2429 if(agony)
2430 {
2431 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2432 }
2433
2434 w->x = x+wx;
2435 w->y = y+wy-(54-yofs)-fakez;
2436 w->z = (z+zofs);
2437 w->tile = t;
2438 w->flip = f;
2439 w->hxsz=20;
2440 w->hysz=20;
2441
2442 if(dir>down)
2443 {
2444 w->hysz-=6;
2445 }
2446 else
2447 {
2448 w->hxsz-=6;
2449 w->hyofs=4;
2450 }
2451
2452 w->power = weaponattackpower(itemid);
2453
2454 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2455 {
2456 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_bit(quest_rules,qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2457 }
2458
2459 xofs=oxofs;
2460 yofs=oyofs;
2461 return;
2462 }
2463 1813 }
2464
2/4
✓ Branch 0 taken 85098 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 85098 times.
85098 else if(!charging && !spins) // remove the sword
2465 {
2466
2/2
✓ Branch 0 taken 13902 times.
✓ Branch 1 taken 85098 times.
99000 for(int32_t i=0; i<Lwpns.Count(); i++)
2467 {
2468 13902 weapon *w = (weapon*)Lwpns.spr(i);
2469
2470
3/6
✓ Branch 0 taken 13902 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13902 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13902 times.
13902 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2471 w->dead=1;
2472 13902 }
2473 85098 }
2474
2475
2/2
✓ Branch 0 taken 1923 times.
✓ Branch 1 taken 84988 times.
86911 if(invisible)
2476 {
2477 1923 xofs=oxofs;
2478 1923 yofs=oyofs;
2479 1923 return;
2480 }
2481
2482
2/4
✓ Branch 0 taken 84988 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84988 times.
84988 if(action != casting && action != sideswimcasting)
2483 {
2484 // Keep this consistent with checkspecial2, line 7800-ish...
2485
6/6
✓ Branch 0 taken 521 times.
✓ Branch 1 taken 84467 times.
✓ Branch 2 taken 496 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 485 times.
84988 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2486
2487 84988 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2488 84988 bool noliftspr = get_bit(quest_rules,qr_NO_LIFT_SPRITE);
2489 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2490
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 70362 times.
✓ Branch 3 taken 14626 times.
84988 switch(zinit.heroAnimationStyle)
2491 {
2492 case las_original: //normal
2493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70362 times.
70362 if(action==drowning)
2494 {
2495 if(inwater)
2496 {
2497 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2498 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2499 }
2500 else
2501 {
2502 xofs=oxofs;
2503 yofs=oyofs;
2504 return;
2505 }
2506 }
2507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70362 times.
70362 else if(action==lavadrowning)
2508 {
2509 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2510 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2511 }
2512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70362 times.
70362 else if(action==sidedrowning)
2513 {
2514 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2515 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2516 }
2517
2/4
✓ Branch 0 taken 70362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70362 times.
70362 else if (action == sideswimming || action == sideswimhit)
2518 {
2519 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2520
2521 if(lstep>=6)
2522 {
2523 if(dir==up)
2524 {
2525 if ( script_hero_sprite <= 0 ) ++flip;
2526 }
2527 else
2528 {
2529 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2530 }
2531 }
2532 }
2533
3/6
✓ Branch 0 taken 70362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70362 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 70362 times.
70362 else if(action==swimming || action==swimhit || hopclk==0xFF)
2534 {
2535 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2536
2537 if(lstep>=6)
2538 {
2539 if(dir==up)
2540 {
2541 if ( script_hero_sprite <= 0 ) ++flip;
2542 }
2543 else
2544 {
2545 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2546 }
2547 }
2548
2549 if(isDiving())
2550 {
2551 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2552 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2553 }
2554 }
2555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 70362 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
70362 else if(charging > 0 && attack != wHammer)
2556 {
2557 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2558
2559 if(lstep>=6)
2560 {
2561 if(dir==up)
2562 {
2563 if ( script_hero_sprite <= 0 ) ++flip;
2564 }
2565 else
2566 {
2567 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2568 }
2569 }
2570 }
2571
3/12
✓ Branch 0 taken 70362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70362 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 70362 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
70362 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2572 {
2573 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2574 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2575 }
2576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70362 times.
70362 else if(fallclk>0)
2577 {
2578 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2579 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2580 }
2581
3/6
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 69746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
70362 else if(!noliftspr&&action==lifting&&isLifting())
2582 {
2583 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2584 if(script_hero_sprite <= 0)
2585 {
2586 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2587 auto speed = tliftclk/frames;
2588 if (speed < 1) speed = 1;
2589 auto curframe = (tliftclk - liftclk) / speed;
2590 if (!tliftclk) curframe = frames - 1;
2591 if(unsigned(curframe) < frames)
2592 tile += curframe * (extend == 2 ? 2 : 1);
2593 }
2594 }
2595 else
2596 {
2597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70362 times.
70362 if(IsSideSwim())
2598 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2599
3/4
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 69746 times.
✓ Branch 2 taken 616 times.
✗ Branch 3 not taken.
70362 else if(!noliftspr&&isLifting())
2600 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2601 70362 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2602
2603
2/2
✓ Branch 0 taken 48763 times.
✓ Branch 1 taken 21599 times.
70362 if(dir>up)
2604 {
2605 48763 useltm=true;
2606 48763 shieldModify=true;
2607 48763 }
2608
2609
2/2
✓ Branch 0 taken 34381 times.
✓ Branch 1 taken 35981 times.
70362 if(lstep>=6)
2610 {
2611
2/2
✓ Branch 0 taken 10603 times.
✓ Branch 1 taken 25378 times.
35981 if(dir==up)
2612 {
2613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10603 times.
10603 if ( script_hero_sprite <= 0 ) ++flip;
2614 10603 }
2615 else
2616 {
2617
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25378 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25378 times.
25378 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2618 }
2619 35981 }
2620 }
2621
2622 70362 break;
2623
2624 case las_bszelda: //BS
2625
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 14498 times.
14626 if(action==drowning)
2626 {
2627
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(inwater)
2628 {
2629 128 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2631 128 }
2632 else
2633 {
2634 xofs=oxofs;
2635 yofs=oyofs;
2636 return;
2637 }
2638 128 }
2639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14498 times.
14498 else if (action == sidedrowning)
2640 {
2641 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2642 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2643 }
2644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14498 times.
14498 else if(action==lavadrowning)
2645 {
2646 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2647 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2648 }
2649
2/4
✓ Branch 0 taken 14498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14498 times.
14498 else if (action == sideswimming || action == sideswimhit)
2650 {
2651 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2652
2653 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2654 }
2655
4/6
✓ Branch 0 taken 14202 times.
✓ Branch 1 taken 296 times.
✓ Branch 2 taken 14202 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14202 times.
14498 else if(action==swimming || action==swimhit || hopclk==0xFF)
2656 {
2657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2658 {
2659 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2660 }
2661 else
2662 {
2663 296 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2664 }
2665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2666
2667
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(isDiving())
2668 {
2669 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2670 {
2671 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2672 }
2673 else
2674 {
2675 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2676 }
2677 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2678 }
2679 296 }
2680
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14202 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14202 else if(charging > 0 && attack != wHammer)
2681 {
2682 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2683 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2684 }
2685
7/10
✓ Branch 0 taken 14202 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2075 times.
✓ Branch 5 taken 12127 times.
✓ Branch 6 taken 1624 times.
✓ Branch 7 taken 451 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1624 times.
14202 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2686 {
2687 1624 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1624 times.
1624 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2689 1624 }
2690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12578 times.
12578 else if(fallclk>0)
2691 {
2692 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2693 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2694 }
2695
3/6
✓ Branch 0 taken 12352 times.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12352 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12578 else if(!noliftspr&&action==lifting&&isLifting())
2696 {
2697 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2698 if(script_hero_sprite <= 0)
2699 {
2700 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2701 auto speed = tliftclk/frames;
2702 if (speed < 1) speed = 1;
2703 auto curframe = (tliftclk - liftclk) / speed;
2704 if (!tliftclk) curframe = frames - 1;
2705 if(unsigned(curframe) < frames)
2706 tile += curframe * (extend == 2 ? 2 : 1);
2707 }
2708 }
2709 else
2710 {
2711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12578 times.
12578 if(IsSideSwim())
2712 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2713
3/4
✓ Branch 0 taken 12352 times.
✓ Branch 1 taken 226 times.
✓ Branch 2 taken 12352 times.
✗ Branch 3 not taken.
12578 else if(!noliftspr&&isLifting())
2714 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2715 12578 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2716
2717
2/2
✓ Branch 0 taken 1851 times.
✓ Branch 1 taken 10727 times.
12578 if(dir>up)
2718 {
2719 10727 useltm=true;
2720 10727 shieldModify=true;
2721 10727 }
2722
2723 /*
2724 else if (dir==up)
2725 {
2726 useltm=true;
2727 }
2728 */
2729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12578 times.
12578 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2730 }
2731
2732 14626 break;
2733
2734 case las_zelda3slow: //8-frame Zelda 3 (slow)
2735 case las_zelda3: //8-frame Zelda 3
2736 if(action == drowning)
2737 {
2738 if(inwater)
2739 {
2740 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2741 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2742 }
2743 else
2744 {
2745 xofs=oxofs;
2746 yofs=oyofs;
2747 return;
2748 }
2749 }
2750 else if(action == lavadrowning)
2751 {
2752 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2753 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2754
2755 }
2756 else if(action == sidedrowning)
2757 {
2758 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2759 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2760 }
2761 else if (action == sideswimming || action == sideswimhit)
2762 {
2763 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2764
2765 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2766 }
2767 else if(action == swimming || action==swimhit || hopclk==0xFF)
2768 {
2769 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2770 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2771
2772 if(isDiving())
2773 {
2774 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2775 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2776 }
2777 }
2778 else if(charging > 0 && attack != wHammer)
2779 {
2780 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2781 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2782 //int32_t l=hero_count/hero_animation_speed;
2783 int32_t l=(hero_count/hero_animation_speed)&15;
2784 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2785 l-=((l>3)?1:0)+((l>12)?1:0);
2786 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2787 }
2788 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2789 {
2790 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2791 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2792 }
2793 else if(fallclk>0)
2794 {
2795 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2796 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2797 }
2798 else if(!noliftspr&&action==lifting&&isLifting())
2799 {
2800 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2801 if(script_hero_sprite <= 0)
2802 {
2803 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2804 auto speed = tliftclk/frames;
2805 if (speed < 1) speed = 1;
2806 auto curframe = (tliftclk-liftclk)/speed;
2807 if (!tliftclk) curframe = frames - 1;
2808 if(unsigned(curframe) < frames)
2809 tile += curframe * (extend == 2 ? 2 : 1);
2810 }
2811 }
2812 else
2813 {
2814 if(IsSideSwim())
2815 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2816 else if(!noliftspr&&isLifting())
2817 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2818 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2819
2820 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2821 {
2822 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2823 }
2824
2825 if(dir>up)
2826 {
2827 useltm=true;
2828 shieldModify=true;
2829 }
2830
2831 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2832 {
2833 //tile+=(extend==2?2:1);
2834 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2835 int32_t l = hero_count / hero_animation_speed;
2836 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2837 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2838 }
2839 }
2840
2841 break;
2842
2843 default:
2844 break;
2845 }
2846 84988 }
2847
2848
6/6
✓ Branch 0 taken 69746 times.
✓ Branch 1 taken 15242 times.
✓ Branch 2 taken 45293 times.
✓ Branch 3 taken 24453 times.
✓ Branch 4 taken 1049 times.
✓ Branch 5 taken 44244 times.
84988 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2849
2850
1/2
✓ Branch 0 taken 84988 times.
✗ Branch 1 not taken.
84988 if(action==won)
2851 {
2852 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2853 }
2854
2855
4/4
✓ Branch 0 taken 83558 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 1091 times.
✓ Branch 3 taken 82467 times.
84988 if(action==landhold1 || action==landhold2)
2856 {
2857 2521 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2858
5/6
✓ Branch 0 taken 2521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1481 times.
✓ Branch 3 taken 1040 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 1351 times.
2521 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2859 2521 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2860 2521 }
2861
2/4
✓ Branch 0 taken 82467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82467 times.
82467 else if(action==waterhold1 || action==waterhold2)
2862 {
2863 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2864 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2865 }
2866
2/4
✓ Branch 0 taken 82467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82467 times.
82467 else if(action==sidewaterhold1 || action==sidewaterhold2)
2867 {
2868 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2869 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2870 }
2871
2872
2/4
✓ Branch 0 taken 84988 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84988 times.
84988 if(action!=casting && action!=sideswimcasting)
2873 {
2874
2/2
✓ Branch 0 taken 22736 times.
✓ Branch 1 taken 62252 times.
84988 if(useltm)
2875 {
2876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62252 times.
62252 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2877 62252 }
2878 84988 }
2879
2880 // Stone of Agony
2881
1/2
✓ Branch 0 taken 84988 times.
✗ Branch 1 not taken.
84988 if(agony)
2882 {
2883 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2884 }
2885
2886
5/6
✓ Branch 0 taken 3577 times.
✓ Branch 1 taken 81411 times.
✓ Branch 2 taken 3577 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 3484 times.
84988 if(!(get_bit(quest_rules,qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2887 {
2888 84895 masked_draw(dest);
2889 84895 }
2890
2891 //draw held items after Hero so they don't go behind his head
2892
4/4
✓ Branch 0 taken 83558 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 1091 times.
✓ Branch 3 taken 82467 times.
84988 if(action==landhold1 || action==landhold2)
2893 {
2894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2521 times.
2521 if(holditem > -1)
2895 {
2896
2/2
✓ Branch 0 taken 1131 times.
✓ Branch 1 taken 1390 times.
2521 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2897 {
2898 1131 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2899 1131 }
2900 else
2901 {
2902 1390 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2903 }
2904 2521 }
2905 2521 }
2906
2/4
✓ Branch 0 taken 82467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82467 times.
82467 else if(action==waterhold1 || action==waterhold2)
2907 {
2908 if(holditem > -1)
2909 {
2910 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2911 {
2912 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2913 }
2914 else
2915 {
2916 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2917 }
2918 }
2919 }
2920
2/4
✓ Branch 0 taken 82467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82467 times.
82467 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2921 {
2922 if(holditem > -1)
2923 {
2924 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2925 {
2926 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2927 }
2928 else
2929 {
2930 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2931 }
2932 }
2933 }
2934
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 84905 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
84988 if(fairyclk==0||(get_bit(quest_rules,qr_NOHEARTRING)))
2935 {
2936 84905 xofs=oxofs;
2937 84905 yofs=oyofs;
2938 84905 return;
2939 }
2940
2941 83 double a2 = fairyclk*int64_t(2)*PI/80 + (PI/2);
2942 83 int32_t hearts=0;
2943 // int32_t htile = QHeader.dat_flags[ZQ_TILES] ? 2 : 0;
2944 83 int32_t htile = 2;
2945
2946 83 do
2947 {
2948 384 int32_t nx=125;
2949
2950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2951 {
2952 384 nx=x;
2953 384 }
2954
2955 384 int32_t ny=88;
2956
2957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2958 {
2959 384 ny=y;
2960 384 }
2961
2962 384 double tx = zc::math::Cos(a2)*53 +nx;
2963 384 double ty = -zc::math::Sin(a2)*53 +ny+playing_field_offset;
2964 384 overtile8(dest,htile,int32_t(tx),int32_t(ty),1,0);
2965 384 a2-=PI/4;
2966 384 ++hearts;
2967
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 83 times.
768 }
2968
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 304 times.
384 while(a2>PI/2 && hearts<8);
2969
2970 83 xofs=oxofs;
2971 83 yofs=oyofs;
2972 93748 }
2973
2974 91729 void HeroClass::masked_draw(BITMAP* dest)
2975 {
2976
12/12
✓ Branch 0 taken 49827 times.
✓ Branch 1 taken 41902 times.
✓ Branch 2 taken 48688 times.
✓ Branch 3 taken 1139 times.
✓ Branch 4 taken 47419 times.
✓ Branch 5 taken 1269 times.
✓ Branch 6 taken 45869 times.
✓ Branch 7 taken 1550 times.
✓ Branch 8 taken 44912 times.
✓ Branch 9 taken 957 times.
✓ Branch 10 taken 46859 times.
✓ Branch 11 taken 1829 times.
91729 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_bit(quest_rules,qr_FREEFORM))
2977 {
2978 // clip under doorways
2979 1829 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
2980
2981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
1829 if(sub!=NULL)
2982 {
2983 1829 yofs -= (playing_field_offset+16);
2984 1829 xofs -= 16;
2985 1829 sprite::draw(sub);
2986
1/2
✓ Branch 0 taken 1829 times.
✗ Branch 1 not taken.
1829 if(lift_wpn)
2987 {
2988 handle_lift(false);
2989 bool shad = lift_wpn->has_shadow;
2990 lift_wpn->has_shadow = false;
2991 lift_wpn->draw(sub);
2992 lift_wpn->has_shadow = shad;
2993 }
2994 1829 prompt_draw(sub);
2995 1829 xofs+=16;
2996 1829 yofs += (playing_field_offset+16);
2997 1829 destroy_bitmap(sub);
2998 1829 }
2999 1829 }
3000 else
3001 {
3002 89900 sprite::draw(dest);
3003
1/2
✓ Branch 0 taken 89900 times.
✗ Branch 1 not taken.
89900 if(lift_wpn)
3004 {
3005 handle_lift(false);
3006 bool shad = lift_wpn->has_shadow;
3007 lift_wpn->has_shadow = false;
3008 lift_wpn->draw(dest);
3009 lift_wpn->has_shadow = shad;
3010 }
3011 89900 prompt_draw(dest);
3012 }
3013
3014 91729 return;
3015 }
3016 91729 void HeroClass::prompt_draw(BITMAP* dest)
3017 {
3018
1/2
✓ Branch 0 taken 91729 times.
✗ Branch 1 not taken.
91729 if(!prompt_combo) return;
3019 int32_t sx = real_x(x+xofs+prompt_x);
3020 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3021 sy -= fake_z(fakez);
3022 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3023 return;
3024 91729 }
3025
3026 121 void collectitem_script(int32_t id)
3027 {
3028
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if(itemsbuf[id].collect_script)
3029 {
3030 //clear item script stack.
3031 //ri = &(itemScriptData[id]);
3032 //ri->Clear();
3033 //itemCollectScriptData[id].Clear();
3034 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0;
3035 ri = &(itemCollectScriptData[id]);
3036 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0xFFFF;
3037 ri->Clear();
3038 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id & 0xFFF)*-1));
3039
3040 if ( id > 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3041 {
3042 item_collect_doscript[id] = 1;
3043 itemscriptInitialised[id] = 0;
3044 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id)*-1));
3045 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3046 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id));
3047 }
3048 else if (id == 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3049 {
3050 item_collect_doscript[id] = 1;
3051 itemscriptInitialised[id] = 0;
3052 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
3053 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3054 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
3055 }
3056 //runningItemScripts[id] = 0;
3057 }
3058 121 }
3059 104 void passiveitem_script(int32_t id, bool doRun = false)
3060 {
3061 //Passive item scripts on colelction
3062
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING)) ))
3063 {
3064 ri = &(itemScriptData[id]);
3065 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id][q] = 0xFFFF;
3066 ri->Clear();
3067 item_doscript[id] = 1;
3068 itemscriptInitialised[id] = 0;
3069
3070
3071 if(get_bit(quest_rules,qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3072 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3073 {
3074 item_doscript[id] = 0;
3075 return;
3076 }
3077 if(doRun)
3078 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].script, id);
3079 }
3080 104 }
3081
3082 // separate case for sword/wand/hammer/slashed weapons only
3083 // the main weapon checking is in the global function check_collisions()
3084 79959 bool HeroClass::checkstab()
3085 {
3086
10/14
✓ Branch 0 taken 71411 times.
✓ Branch 1 taken 8548 times.
✓ Branch 2 taken 2410 times.
✓ Branch 3 taken 6138 times.
✓ Branch 4 taken 2410 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2410 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2410 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2410 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1772 times.
✓ Branch 13 taken 4366 times.
79959 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3087 8548 || (attackclk<=4))
3088 75593 return false;
3089
3090 4366 weapon *w=NULL;
3091
3092 4366 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3093 4366 bool found = false;
3094 4366 int32_t melee_weapon_index = 0;
3095 4366 int32_t parentitem=-1;
3096 4366 weapon* meleeweap = nullptr;
3097
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 4788 times.
5219 for(int32_t i=0; i<Lwpns.Count(); i++)
3098 {
3099 4788 w = (weapon*)Lwpns.spr(i);
3100
3101
4/6
✓ Branch 0 taken 4788 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4788 times.
✓ Branch 4 taken 853 times.
✓ Branch 5 taken 3935 times.
4788 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3102 {
3103 3935 found = true;
3104 3935 melee_weapon_index = i+1;
3105 3935 meleeweap = w;
3106 // Position the sword as Hero slashes with it.
3107
2/4
✓ Branch 0 taken 3935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3935 times.
3935 if(w->id!=wHammer&&w->id!=wBugNet)
3108 3935 positionSword(w,w->parentitem);
3109
3110 3935 wx=w->x;
3111 3935 wy=w->y;
3112 3935 wz=w->z;
3113 3935 wxsz = w->hxsz;
3114 3935 wysz = w->hysz;
3115 3935 parentitem = w->parentitem;
3116 3935 break;
3117 }
3118 853 }
3119
3120
4/6
✓ Branch 0 taken 4366 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 438 times.
✓ Branch 3 taken 3928 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 438 times.
4366 if(attack==wSword && attackclk>=14 && charging==0)
3121 438 return false;
3122
3123
2/2
✓ Branch 0 taken 3497 times.
✓ Branch 1 taken 431 times.
3928 if(!found)
3124 431 return false;
3125
3126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3497 times.
3497 if(attack == wFire)
3127 return false;
3128
3129
1/2
✓ Branch 0 taken 3497 times.
✗ Branch 1 not taken.
3497 if(attack==wHammer)
3130 {
3131 if(attackclk<15)
3132 {
3133 switch(w->dir)
3134 {
3135 case up:
3136 wx=x-1;
3137 wy=y-4;
3138 break;
3139
3140 case down:
3141 wx=x+8;
3142 wy=y+28;
3143 break; // This is consistent with 2.10
3144
3145 case left:
3146 wx=x-13;
3147 wy=y+14;
3148 break;
3149
3150 case right:
3151 wx=x+21;
3152 wy=y+14;
3153 break;
3154 }
3155
3156 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3157 {
3158 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3159 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3160 switch(dir)
3161 {
3162 case up:
3163 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3164 break;
3165
3166 case down:
3167 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3168 break;
3169
3170 case left:
3171 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3172 break;
3173
3174 case right:
3175 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3176 break;
3177 }
3178 */
3179 }
3180
3181 return false;
3182 }
3183 else if(attackclk==15)
3184 {
3185 // Hammer's reach needs adjusted slightly for backward compatibility
3186 if(w->dir==up)
3187 w->hyofs-=1;
3188 else if(w->dir==left)
3189 w->hxofs-=2;
3190 }
3191 }
3192
3193 // The return of Spaghetti Code Constants!
3194
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3497 times.
✓ Branch 2 taken 3497 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3497 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3195
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3497 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3196 3497 itemid = vbound(itemid, 0, MAXITEMS-1);
3197
3198 // The sword offsets aren't based on anything other than what felt about right
3199 // compared to the NES game and what mostly kept it from hitting things that
3200 // should clearly be out of range. They could probably still use more tweaking.
3201 // Don't use 2.10 for reference; it's pretty far off.
3202 // - Saf
3203
3204
4/6
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 3421 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 76 times.
3497 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3205 {
3206
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 58 times.
76 switch(w->dir)
3207 {
3208 case up:
3209
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(attackclk<8)
3210 {
3211 9 wy-=4;
3212 9 }
3213
3214 18 break;
3215
3216 case down:
3217 //if(attackclk<8)
3218 {
3219 wy-=2;
3220 }
3221 break;
3222
3223 case left:
3224
3225 //if(attackclk<8)
3226 {
3227 wx+=2;
3228 }
3229
3230 break;
3231
3232 case right:
3233
3234 //if(attackclk<8)
3235 {
3236 58 wx-=3;
3237 //wy+=((spins>0 || get_bit(quest_rules, qr_SLASHFLIPFIX)) ? -4 : 4);
3238 }
3239
3240 58 break;
3241 }
3242 76 }
3243
3244
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 522 times.
✓ Branch 2 taken 505 times.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 1486 times.
3497 switch(w->dir)
3245 {
3246 case up:
3247 522 wx+=2;
3248 522 break;
3249
3250 case down:
3251 505 break;
3252
3253 case left:
3254 984 wy-=3;
3255 984 break;
3256
3257 case right:
3258 1486 wy-=3;
3259 1486 break;
3260 }
3261
3262 3497 wx+=w->hxofs;
3263 3497 wy+=w->hyofs;
3264 3497 wy-=(w->fakez).getInt();
3265
3266
2/2
✓ Branch 0 taken 3497 times.
✓ Branch 1 taken 10208 times.
13705 for(int32_t i=0; i<guys.Count(); i++)
3267 {
3268
1/2
✓ Branch 0 taken 10208 times.
✗ Branch 1 not taken.
10208 if(attack==wBugNet) break;
3269 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3270
4/6
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 10033 times.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 175 times.
✗ Branch 5 not taken.
10208 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3271
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 10033 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10033 times.
10033 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3272
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10033 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10033 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3273 {
3274 // Checking the whimsical ring for every collision check causes
3275 // an odd bug. It's much more likely to activate on a 0-damage
3276 // weapon, since a 0-damage hit won't make the enemy invulnerable
3277 // to damaging hits in the following frames.
3278
3279 175 int32_t whimsyid = current_item_id(itype_whimsicalring);
3280
3281 175 int32_t dmg = weaponattackpower(itemid);
3282
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(whimsyid>-1)
3283 {
3284 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3285 dmg += current_item_power(itype_whimsicalring);
3286 else whimsyid = -1;
3287 }
3288 175 int32_t atkringid = current_item_id(itype_atkring);
3289
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(atkringid>-1)
3290 {
3291 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3292 dmg += itemsbuf[atkringid].misc1; //Additive
3293 }
3294
3295 175 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn);
3296 175 enemy *e = (enemy*)guys.spr(i);
3297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175 times.
175 if (h == -1) { e->hitby[HIT_BY_LWEAPON] = melee_weapon_index; } //temp_hit = true; }
3298 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3299
3300
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
175 if(h<0 && whimsyid>-1)
3301 {
3302 sfx(itemsbuf[whimsyid].usesound);
3303 }
3304
3305
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(h && charging>0)
3306 {
3307 attackclk = SWORDTAPFRAME;
3308 spins=0;
3309 }
3310
3311
5/8
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 171 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 171 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 171 times.
175 if(h && hclk==0 && inlikelike != 1 && !get_bit(quest_rules, qr_DYING_ENEMIES_IGNORE_STUN))
3312 {
3313
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 2 times.
171 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3314 {
3315 2 hithero(i);
3316 2 }
3317 171 }
3318
3319
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(h==2)
3320 break;
3321 175 }
3322 10208 }
3323
3324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3497 times.
6994 if(attack == wBugNet
3325
2/4
✓ Branch 0 taken 3497 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3497 times.
3497 || (parentitem==-1&&!get_bit(quest_rules,qr_NOITEMMELEE))
3326
1/2
✓ Branch 0 taken 3497 times.
✗ Branch 1 not taken.
3497 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3327 {
3328
1/4
✓ Branch 0 taken 3497 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3497 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3329
2/2
✓ Branch 0 taken 3497 times.
✓ Branch 1 taken 997 times.
4494 for(int32_t j=0; j<items.Count(); j++)
3330 {
3331 997 item* ptr = (item*)items.spr(j);
3332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 997 times.
997 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3333 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3334
3335
2/4
✓ Branch 0 taken 997 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 997 times.
✗ Branch 3 not taken.
997 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3336 continue; //No picking these up unless you have a bottle to fill!
3337
4/6
✓ Branch 0 taken 997 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 709 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 288 times.
997 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3338 {
3339
6/8
✓ Branch 0 taken 709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 499 times.
✓ Branch 4 taken 499 times.
✓ Branch 5 taken 210 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 499 times.
709 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3340 {
3341
5/6
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 480 times.
✓ Branch 4 taken 480 times.
✓ Branch 5 taken 19 times.
979 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3342
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
480 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3343 {
3344 19 int32_t pickup = ptr->pickup;
3345 19 int32_t id2 = ptr->id;
3346 19 int32_t pstr = ptr->pstring;
3347 19 int32_t pstr_flags = ptr->pickup_string_flags;
3348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(!dofairy)
3349 {
3350 19 std::vector<int32_t> &ev = FFCore.eventData;
3351 19 ev.clear();
3352 19 ev.push_back(id2*10000);
3353 19 ev.push_back(pickup*10000);
3354 19 ev.push_back(pstr*10000);
3355 19 ev.push_back(pstr_flags*10000);
3356 19 ev.push_back(0);
3357 19 ev.push_back(ptr->getUID());
3358 19 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3359 19 ev.push_back(w->getUID());
3360
3361 19 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3362 19 bool nullify = ev[4] != 0;
3363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(nullify) continue;
3364 19 id2 = ev[0]/10000;
3365 19 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3366 19 pstr = ev[2] / 10000;
3367 19 pstr_flags = ev[3] / 10000;
3368 19 }
3369
3370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(pickup&ipONETIME) // set mITEM for one-time-only items
3371 setmapflag(mITEM);
3372
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3373 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3374
3375
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3376 setxmapflag(1<<ptr->pickupexstate);
3377
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3378 {
3379 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3380 hidden_entrance(0, true, false, -5);
3381 }
3382 //!DIMI
3383
3384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(dofairy)
3385 {
3386 game->fillBottle(itemsbuf[ptr->id].misc4);
3387 }
3388 else
3389 {
3390 19 collectitem_script(id2);
3391
3392 19 getitem(id2, false, true);
3393 }
3394 19 items.del(j);
3395
3396
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 19 times.
39 for(int32_t i=0; i<Lwpns.Count(); i++)
3397 {
3398 20 weapon *w2 = (weapon*)Lwpns.spr(i);
3399
3400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(w2->dragging==j)
3401 {
3402 w2->dragging=-1;
3403 }
3404
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 else if(w2->dragging>j)
3405 {
3406 w2->dragging-=1;
3407 }
3408 20 }
3409
3410
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19 if ( (pstr > 0 && pstr < msg_count) )
3411 {
3412 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3413 {
3414 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3415 FFCore.SetItemMessagePlayed(id2);
3416 donewmsg(pstr);
3417 break;
3418 }
3419 }
3420
3421 19 --j;
3422 19 }
3423 499 }
3424 709 }
3425 997 }
3426 3497 }
3427
3428
2/4
✓ Branch 0 taken 3497 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3497 times.
3497 if(attack==wCByrna || attack==wBugNet)
3429 return false;
3430
3431
1/2
✓ Branch 0 taken 3497 times.
✗ Branch 1 not taken.
3497 if(attack==wSword)
3432 {
3433
2/2
✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 441 times.
3497 if(attackclk == 6)
3434 {
3435
2/2
✓ Branch 0 taken 77616 times.
✓ Branch 1 taken 441 times.
78057 for(int32_t q=0; q<176; q++)
3436 {
3437 77616 set_bit(screengrid,q,0);
3438 77616 set_bit(screengrid_layer[0],q,0);
3439 77616 set_bit(screengrid_layer[1],q,0);
3440
3441 77616 }
3442
3443
2/2
✓ Branch 0 taken 7056 times.
✓ Branch 1 taken 441 times.
7497 for(dword q = MAXFFCS/8; q > 0; --q)
3444 7056 ffcgrid[q-1] = 0;
3445 441 }
3446
3447
4/4
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 2975 times.
✓ Branch 2 taken 177 times.
✓ Branch 3 taken 345 times.
3497 if(dir==up && ((x.getInt()&15)==0))
3448 {
3449 345 check_slash_block(wx,wy);
3450 345 check_slash_block(wx,wy+8);
3451
3452 //layers
3453 345 check_slash_block_layer(wx,wy,1);
3454 345 check_slash_block_layer(wx,wy+8,1);
3455 345 check_slash_block_layer(wx,wy,1);
3456 345 check_slash_block_layer(wx,wy+8,1);
3457 //2
3458 345 check_slash_block_layer(wx,wy,2);
3459 345 check_slash_block_layer(wx,wy+8,2);
3460 345 check_slash_block_layer(wx,wy,2);
3461 345 check_slash_block_layer(wx,wy+8,2);
3462
3463
3464
3465 345 }
3466
5/8
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 2975 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 166 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3152 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3467 {
3468 177 check_slash_block(wx,wy);
3469 177 check_slash_block(wx,wy+8);
3470 177 check_slash_block(wx+8,wy);
3471 177 check_slash_block(wx+8,wy+8);
3472 ///layer 1
3473 177 check_slash_block_layer(wx,wy,1);
3474 177 check_slash_block_layer(wx,wy+8,1);
3475 177 check_slash_block_layer(wx+8,wy,1);
3476 177 check_slash_block_layer(wx+8,wy+8,1);
3477 ///layer 2
3478 177 check_slash_block_layer(wx,wy,2);
3479 177 check_slash_block_layer(wx,wy+8,2);
3480 177 check_slash_block_layer(wx+8,wy,2);
3481 177 check_slash_block_layer(wx+8,wy+8,2);
3482 177 }
3483
3484
4/4
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 2992 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 209 times.
3497 if(dir==down && ((x.getInt()&15)==0))
3485 {
3486 296 check_slash_block(wx,wy+wysz-8);
3487 296 check_slash_block(wx,wy+wysz);
3488
3489 //layer 1
3490 296 check_slash_block_layer(wx,wy+wysz-8,1);
3491 296 check_slash_block_layer(wx,wy+wysz,1);
3492 //layer 2
3493 296 check_slash_block_layer(wx,wy+wysz-8,2);
3494 296 check_slash_block_layer(wx,wy+wysz,2);
3495 296 }
3496
3/8
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 2992 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 209 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3201 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3497 {
3498 209 check_slash_block(wx,wy+wysz-8);
3499 209 check_slash_block(wx,wy+wysz);
3500 209 check_slash_block(wx+8,wy+wysz-8);
3501 209 check_slash_block(wx+8,wy+wysz);
3502 //layer 1
3503 209 check_slash_block_layer(wx,wy+wysz-8,1);
3504 209 check_slash_block_layer(wx,wy+wysz,1);
3505 209 check_slash_block_layer(wx+8,wy+wysz-8,1);
3506 209 check_slash_block_layer(wx+8,wy+wysz,1);
3507 //layer 2
3508 209 check_slash_block_layer(wx,wy+wysz-8,2);
3509 209 check_slash_block_layer(wx,wy+wysz,2);
3510 209 check_slash_block_layer(wx+8,wy+wysz-8,2);
3511 209 check_slash_block_layer(wx+8,wy+wysz,2);
3512 209 }
3513
3514
2/2
✓ Branch 0 taken 2513 times.
✓ Branch 1 taken 984 times.
3497 if(dir==left)
3515 {
3516 984 check_slash_block(wx,wy+8);
3517 984 check_slash_block(wx+8,wy+8);
3518 //layer 1
3519 984 check_slash_block_layer(wx,wy+8,1);
3520 984 check_slash_block_layer(wx+8,wy+8,1);
3521 //layer 2
3522 984 check_slash_block_layer(wx,wy+8,2);
3523 984 check_slash_block_layer(wx+8,wy+8,2);
3524 984 }
3525
3526
2/2
✓ Branch 0 taken 2011 times.
✓ Branch 1 taken 1486 times.
3497 if(dir==right)
3527 {
3528 1486 check_slash_block(wx+wxsz,wy+8);
3529 1486 check_slash_block(wx+wxsz-8,wy+8);
3530 //layer 1
3531 1486 check_slash_block_layer(wx+wxsz,wy+8,1);
3532 1486 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3533 //layer 2
3534 1486 check_slash_block_layer(wx+wxsz,wy+8,2);
3535 1486 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3536 1486 }
3537 3497 }
3538 else if(attack==wWand)
3539 {
3540 if(attackclk == 5)
3541 {
3542 for(int32_t q=0; q<176; q++)
3543 {
3544 set_bit(screengrid,q,0);
3545 set_bit(screengrid_layer[0],q,0);
3546 set_bit(screengrid_layer[1],q,0);
3547 }
3548
3549 for(dword q = MAXFFCS/8; q > 0; --q)
3550 ffcgrid[q-1] = 0;
3551 }
3552
3553 // cutable blocks
3554 if(dir==up && (x.getInt()&15)==0)
3555 {
3556 check_wand_block(wx,wy);
3557 check_wand_block(wx,wy+8);
3558 }
3559 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3560 {
3561 check_wand_block(wx,wy);
3562 check_wand_block(wx,wy+8);
3563 check_wand_block(wx+8,wy);
3564 check_wand_block(wx+8,wy+8);
3565 }
3566
3567 if(dir==down && (x.getInt()&15)==0)
3568 {
3569 check_wand_block(wx,wy+wysz-8);
3570 check_wand_block(wx,wy+wysz);
3571 }
3572 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3573 {
3574 check_wand_block(wx,wy+wysz-8);
3575 check_wand_block(wx,wy+wysz);
3576 check_wand_block(wx+8,wy+wysz-8);
3577 check_wand_block(wx+8,wy+wysz);
3578 }
3579
3580 if(dir==left)
3581 {
3582 check_wand_block(wx,y+8);
3583 check_wand_block(wx+8,y+8);
3584 }
3585
3586 if(dir==right)
3587 {
3588 check_wand_block(wx+wxsz,y+8);
3589 check_wand_block(wx+wxsz-8,y+8);
3590 }
3591 }
3592 else if((attack==wHammer) && ((attackclk==15) || ( spins==1 && attackclk >=15 ))) //quake hammer should be spins == 1
3593 //else if((attack==wHammer) && (attackclk==15))
3594 //reverting this, because it breaks multiple-hit pegs
3595 //else if((attack==wHammer) && (attackclk>=15)) //>= instead of == for time it takes to charge up hammer with quake scrolls.
3596 {
3597 // poundable blocks
3598 for(int32_t q=0; q<176; q++)
3599 {
3600 set_bit(screengrid,q,0);
3601 set_bit(screengrid_layer[0],q,0);
3602 set_bit(screengrid_layer[1],q,0);
3603 }
3604
3605 for(dword q = MAXFFCS/8; q > 0; --q)
3606 ffcgrid[q-1] = 0;
3607
3608 if(dir==up && (x.getInt()&15)==0)
3609 {
3610 check_pound_block(wx,wy);
3611 check_pound_block(wx,wy+8);
3612 }
3613 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3614 {
3615 check_pound_block(wx,wy);
3616 check_pound_block(wx,wy+8);
3617 check_pound_block(wx+8,wy);
3618 check_pound_block(wx+8,wy+8);
3619 }
3620
3621 if(dir==down && (x.getInt()&15)==0)
3622 {
3623 check_pound_block(wx,wy+wysz-8);
3624 check_pound_block(wx,wy+wysz);
3625 }
3626 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3627 {
3628 check_pound_block(wx,wy+wysz-8);
3629 check_pound_block(wx,wy+wysz);
3630 check_pound_block(wx+8,wy+wysz-8);
3631 check_pound_block(wx+8,wy+wysz);
3632 }
3633
3634 if(dir==left)
3635 {
3636 check_pound_block(wx,y+8);
3637 check_pound_block(wx+8,y+8);
3638 }
3639
3640 if(dir==right)
3641 {
3642 check_pound_block(wx+wxsz,y+8);
3643 check_pound_block(wx+wxsz-8,y+8);
3644 }
3645 }
3646 else
3647 {
3648 return false;
3649 }
3650
3651 3497 return true;
3652 79959 }
3653
3654 16912 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3655 {
3656
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 16536 times.
16912 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
3657 {
3658 //zprint("bit off\n");
3659 16536 return;
3660 }
3661 //keep things inside the screen boundaries
3662 376 bx=vbound(bx, 0, 255);
3663 376 by=vbound(by, 0, 176);
3664 376 int32_t fx=vbound(bx, 0, 255);
3665 376 int32_t fy=vbound(by, 0, 176);
3666 //first things first
3667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376 times.
376 if(attack!=wSword)
3668 return;
3669
3670
3/6
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
404 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3671
3/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 348 times.
376 || (attackclk>SWORDTAPFRAME && tapping))
3672 return;
3673
3674 //find out which combo row/column the coordinates are in
3675 376 bx &= 0xF0;
3676 376 by &= 0xF0;
3677
3678
3679 376 int32_t flag = MAPFLAGL(layer,bx,by);
3680 376 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3681 376 int32_t cid = MAPCOMBOL(layer,bx,by);
3682 376 int32_t type = combobuf[cid].type;
3683
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3684 type = cNONE;
3685 //zprint("cid is: %d\n", cid);
3686 //zprint("type is: %d\n", type);
3687 376 int32_t i = (bx>>4) + by;
3688
3689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376 times.
376 if(i > 175)
3690 return;
3691
3692 376 bool ignorescreen=false;
3693
3694
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3695 376 return;
3696
3697 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3698
3699 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3700 if(isCuttableNextType(type))
3701 {
3702 FFCore.tempScreens[layer]->data[i]++;
3703 }
3704 else
3705 {
3706 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3707 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3708 FFCore.tempScreens[layer]->sflag[i] = 0;
3709 }
3710 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3711 {
3712 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3713 sfx(tmpscr->secretsfx);
3714 }
3715 else if(isCuttableItemType(type))
3716 {
3717 int32_t it = -1;
3718 int32_t thedropset = -1;
3719
3720 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3721 if ( (combobuf[cid].usrflags&cflag2) )
3722 {
3723 if(combobuf[cid].usrflags&cflag11)
3724 it = combobuf[cid].attribytes[1];
3725 else
3726 {
3727 it = select_dropitem(combobuf[cid].attribytes[1]);
3728 thedropset = combobuf[cid].attribytes[1];
3729 }
3730 }
3731 else
3732 {
3733 it = select_dropitem(12);
3734 thedropset = 12;
3735 }
3736 if(it!=-1)
3737 {
3738 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3739 itm->from_dropset = thedropset;
3740 items.add(itm);
3741 }
3742 }
3743
3744 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3745
3746 if(get_bit(quest_rules,qr_MORESOUNDS))
3747 {
3748 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3749 {
3750 if (combobuf[cid].usrflags&cflag3)
3751 {
3752 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3753 }
3754 }
3755 else
3756 {
3757 if (combobuf[cid].usrflags&cflag3)
3758 {
3759 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3760 }
3761 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3762 }
3763 }
3764
3765 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
3766 if(decotype > 3) decotype = 0;
3767 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
3768 switch(decotype)
3769 {
3770 case -2: break; //nothing
3771 case -1:
3772 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
3773 break;
3774 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
3775 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
3776 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
3777 }
3778 16912 }
3779
3780 7766 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3781 {
3782 //keep things inside the screen boundaries
3783 7766 bx=vbound(bx, 0, 255);
3784 7766 by=vbound(by, 0, 176);
3785 7766 int32_t fx=vbound(bx, 0, 255);
3786 7766 int32_t fy=vbound(by, 0, 176);
3787 //first things first
3788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7766 times.
7766 if(attack!=wSword)
3789 return;
3790
3791
3/6
✓ Branch 0 taken 7766 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7766 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 960 times.
8726 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3792
3/4
✓ Branch 0 taken 7766 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 6806 times.
7766 || (attackclk>SWORDTAPFRAME && tapping))
3793 return;
3794
3795 //find out which combo row/column the coordinates are in
3796 7766 bx &= 0xF0;
3797 7766 by &= 0xF0;
3798
3799 7766 int32_t type = COMBOTYPE(bx,by);
3800 7766 int32_t type2 = FFCOMBOTYPE(fx,fy);
3801 7766 int32_t flag = MAPFLAG(bx,by);
3802 7766 int32_t flag2 = MAPCOMBOFLAG(bx,by);
3803 7766 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
3804 7766 int32_t cid = MAPCOMBO(bx,by);
3805 7766 int32_t i = (bx>>4) + by;
3806
3807
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 7758 times.
7766 if(i > 175)
3808 8 return;
3809
3810 7758 bool ignorescreen=false;
3811 7758 bool ignoreffc=false;
3812
3813
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 7622 times.
7758 if(get_bit(screengrid, i) != 0)
3814 {
3815 136 ignorescreen = true;
3816 136 }
3817
1/2
✓ Branch 0 taken 7622 times.
✗ Branch 1 not taken.
7622 else if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3818 ignorescreen = true;
3819
3820 7758 int32_t current_ffcombo = getFFCAt(fx,fy);
3821
3822
3823
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7758 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7758 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3824 {
3825 7758 ignoreffc = true;
3826 7758 }
3827 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
3828 ignoreffc = true;
3829
3830
3/4
✓ Branch 0 taken 7713 times.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7713 times.
15471 if(!isCuttableType(type) &&
3831
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7713 times.
✓ Branch 2 taken 7713 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7713 times.
7713 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3832 {
3833 7713 ignorescreen = true;
3834 7713 }
3835
3836
2/4
✓ Branch 0 taken 7758 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7758 times.
15516 if(!isCuttableType(type2) &&
3837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7758 times.
7758 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3838 {
3839 7758 ignoreffc = true;
3840 7758 }
3841
3842 7758 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3843
3844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7758 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7758 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3845 7758 byte skipsecrets = 0;
3846
3847
2/2
✓ Branch 0 taken 7713 times.
✓ Branch 1 taken 45 times.
7758 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3848 {
3849
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
3850 {
3851 45 skipsecrets = 0;
3852 45 }
3853 else skipsecrets = 1; ;
3854 45 }
3855
3856
3/6
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 7741 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7758 if(!ignorescreen && (!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3857 {
3858
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3859 {
3860 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3861 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3862 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3863 }
3864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(flag == mfARMOS_SECRET)
3865 {
3866 s->data[i] = s->secretcombo[sSTAIRS];
3867 s->cset[i] = s->secretcset[sSTAIRS];
3868 s->sflag[i] = s->secretflag[sSTAIRS];
3869 sfx(tmpscr->secretsfx);
3870 }
3871
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
17 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3872 {
3873 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3874 {
3875 findentrance(bx,by,mfSWORD+i2,true);
3876 }
3877
3878 findentrance(bx,by,mfSTRIKE,true);
3879 }
3880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17 else if(((flag2 >= 16)&&(flag2 <= 31)))
3881 {
3882 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3883 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3884 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3885 }
3886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(flag2 == mfARMOS_SECRET)
3887 {
3888 s->data[i] = s->secretcombo[sSTAIRS];
3889 s->cset[i] = s->secretcset[sSTAIRS];
3890 s->sflag[i] = s->secretflag[sSTAIRS];
3891 sfx(tmpscr->secretsfx);
3892 }
3893
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
17 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3894 {
3895 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3896 {
3897 findentrance(bx,by,mfSWORD+i2,true);
3898 }
3899
3900 findentrance(bx,by,mfSTRIKE,true);
3901 }
3902 else
3903 {
3904
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(isCuttableNextType(type))
3905 {
3906 17 s->data[i]++;
3907 17 }
3908 else
3909 {
3910 s->data[i] = s->undercombo;
3911 s->cset[i] = s->undercset;
3912 s->sflag[i] = 0;
3913 }
3914
3915 //pausenow=true;
3916 }
3917 17 }
3918
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7741 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7741 else if(!ignorescreen && skipsecrets)
3919 {
3920 if(isCuttableNextType(type))
3921 {
3922 s->data[i]++;
3923 }
3924 else
3925 {
3926 s->data[i] = s->undercombo;
3927 s->cset[i] = s->undercset;
3928 s->sflag[i] = 0;
3929 }
3930 }
3931
3932
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7758 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7758 times.
7758 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3933 {
3934 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3935 {
3936 findentrance(bx,by,mfSWORD+i2,true);
3937 }
3938
3939 findentrance(fx,fy,mfSTRIKE,true);
3940 }
3941
1/2
✓ Branch 0 taken 7758 times.
✗ Branch 1 not taken.
7758 else if(!ignoreffc)
3942 {
3943 if(isCuttableNextType(type2))
3944 {
3945 s->ffcs[current_ffcombo].incData(1);
3946 }
3947 else
3948 {
3949 s->ffcs[current_ffcombo].setData(s->undercombo);
3950 s->ffcs[current_ffcombo].cset = s->undercset;
3951 }
3952 }
3953
3954
2/2
✓ Branch 0 taken 7741 times.
✓ Branch 1 taken 17 times.
7758 if(!ignorescreen)
3955 {
3956
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
17 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
3957
3958
2/8
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3959 {
3960 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3961 sfx(tmpscr->secretsfx);
3962 }
3963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(isCuttableItemType(type))
3964 {
3965 17 int32_t it = -1;
3966 17 int32_t thedropset = -1;
3967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
3968 {
3969 if ( combobuf[cid].usrflags&cflag11 )
3970 {
3971 it = combobuf[cid].attribytes[1];
3972 }
3973 else
3974 {
3975 it = select_dropitem(combobuf[cid].attribytes[1]);
3976 thedropset = combobuf[cid].attribytes[1];
3977 }
3978 }
3979 else
3980 {
3981 17 it = select_dropitem(12);
3982 17 thedropset = 12;
3983 }
3984
3985
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2 times.
17 if(it!=-1)
3986 {
3987
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3988 2 itm->from_dropset = thedropset;
3989 2 items.add(itm);
3990 2 }
3991 17 }
3992
3993 17 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
3994
3995
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(get_bit(quest_rules,qr_MORESOUNDS))
3996 {
3997 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3998 {
3999 if (combobuf[cid].usrflags&cflag3)
4000 {
4001 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4002 }
4003 }
4004 else
4005 {
4006 if (combobuf[cid].usrflags&cflag3)
4007 {
4008 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4009 }
4010 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4011 }
4012 }
4013
4014
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4015
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(decotype > 3) decotype = 0;
4016
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
17 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4017
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
17 switch(decotype)
4018 {
4019 case -2: break; //nothing
4020 case -1:
4021 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4022 break;
4023
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4024 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4025
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
14 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4026 }
4027 17 }
4028
4029
1/2
✓ Branch 0 taken 7758 times.
✗ Branch 1 not taken.
7758 if(!ignoreffc)
4030 {
4031 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4032
4033 if(isCuttableItemType(type2))
4034 {
4035 int32_t it=-1;
4036 int32_t thedropset=-1;
4037 if ( (combobuf[cid].usrflags&cflag2) )
4038 {
4039 if(combobuf[cid].usrflags&cflag11)
4040 it = combobuf[cid].attribytes[1];
4041 else
4042 {
4043 it = select_dropitem(combobuf[cid].attribytes[1]);
4044 thedropset = combobuf[cid].attribytes[1];
4045 }
4046 }
4047 else
4048 {
4049 int32_t r=zc_oldrand()%100;
4050
4051 if(r<15)
4052 {
4053 it=iHeart; // 15%
4054 }
4055 else if(r<35)
4056 {
4057 it=iRupy; // 20%
4058 }
4059 }
4060
4061 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4062 {
4063 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4064 itm->from_dropset = thedropset;
4065 items.add(itm);
4066 }
4067 }
4068
4069 if(get_bit(quest_rules,qr_MORESOUNDS))
4070 {
4071 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4072 {
4073 if (combobuf[cid].usrflags&cflag3)
4074 {
4075 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4076 }
4077 }
4078 else
4079 {
4080 if (combobuf[cid].usrflags&cflag3)
4081 {
4082 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4083 }
4084 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4085 }
4086 }
4087
4088 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4089 if(decotype > 3) decotype = 0;
4090 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4091 switch(decotype)
4092 {
4093 case -2: break; //nothing
4094 case -1:
4095 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4096 break;
4097 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4098 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4099 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4100 }
4101 }
4102 7766 }
4103
4104 91668 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4105 {
4106 /*
4107 int32_t par_item = w->parentitem;
4108 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4109 int32_t usewpn = -1;
4110 if ( par_item > -1 )
4111 {
4112 usewpn = itemsbuf[par_item].useweapon;
4113 }
4114 else if ( par_item == -1 && w->ScriptGenerated )
4115 {
4116 usewpn = w->useweapon;
4117 }
4118 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4119
4120 */
4121 91668 bx=vbound(bx, 0, 255);
4122 91668 by=vbound(by, 0, 176);
4123 91668 int32_t cid = MAPCOMBO(bx,by);
4124
1/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 91668 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
91668 switch(w->useweapon)
4125 {
4126 case wArrow:
4127 findentrance(bx,by,mfARROW,true);
4128 findentrance(bx,by,mfSARROW,true);
4129 findentrance(bx,by,mfGARROW,true);
4130 break;
4131 case wBeam:
4132 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4133 break;
4134 case wHookshot:
4135 findentrance(bx,by,mfHOOKSHOT,true);
4136 break;
4137 case wBrang:
4138 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4139 break;
4140 case wMagic:
4141 findentrance(bx,by,mfWANDMAGIC,true);
4142 break;
4143 case wRefMagic:
4144 findentrance(bx,by,mfWANDMAGIC,true);
4145 break;
4146 case wRefBeam:
4147 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4148 break;
4149 //reflected magic needs to happen in mirrors:
4150 //
4151 //findentrance(bx,by,mfREFMAGIC,true)
4152 case wRefFireball:
4153 findentrance(bx,by,mfREFFIREBALL,true);
4154 break;
4155 case wBomb:
4156 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4157 break;
4158
4159 case wSBomb:
4160 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4161 break;
4162
4163 case wFire:
4164 findentrance(bx,by,mfBCANDLE,true);
4165 findentrance(bx,by,mfRCANDLE,true);
4166 findentrance(bx,by,mfWANDFIRE,true);
4167 /* if we want the weapon to die
4168 if (findentrance(bx,by,mfBCANDLE,true) ) dead = 1;
4169 if (findentrance(bx,by,mfRCANDLE,true) ) dead = 1;
4170 if (findentrance(bx,by,mfWANDFIRE,true)) dead = 1;
4171 */
4172 break;
4173
4174 case wScript1:
4175 break;
4176 case wScript2:
4177 break;
4178 case wScript3:
4179 break;
4180 case wScript4:
4181 break;
4182 case wScript5:
4183 break;
4184 case wScript6:
4185 break;
4186 case wScript7:
4187 break;
4188 case wScript8:
4189 break;
4190 case wScript9:
4191 break;
4192 case wScript10:
4193 break;
4194 case wIce:
4195 break;
4196 case wCByrna:
4197 break;
4198 case wWhistle:
4199 break;
4200 case wSSparkle:
4201 case wFSparkle:
4202 break;
4203 case wWind:
4204 break;
4205 case wBait:
4206 break;
4207 case wFlame:
4208 case wThrown:
4209 case wBombos:
4210 case wEther:
4211 case wQuake:
4212 case wSwordLA:
4213 case wSword180:
4214 case wStomp:
4215 break;
4216 case wSword:
4217 case wWand:
4218 //case wCandle:
4219 case wHSHandle:
4220 case wLitBomb:
4221 case wLitSBomb:
4222 break;
4223 91668 default: break;
4224
4225 }
4226 91668 }
4227
4228 183336 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4229 {
4230
4231
2/2
✓ Branch 0 taken 34560 times.
✓ Branch 1 taken 148776 times.
183336 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
4232 {
4233 //zprint("bit off\n");
4234 148776 return;
4235 }
4236 //keep things inside the screen boundaries
4237 34560 bx=vbound(bx, 0, 255);
4238 34560 by=vbound(by, 0, 176);
4239 34560 int32_t fx=vbound(bx, 0, 255);
4240 34560 int32_t fy=vbound(by, 0, 176);
4241 //first things first
4242
1/2
✓ Branch 0 taken 34560 times.
✗ Branch 1 not taken.
34560 if(w->useweapon != wSword)
4243 34560 return;
4244
4245 //find out which combo row/column the coordinates are in
4246 bx &= 0xF0;
4247 by &= 0xF0;
4248
4249
4250 int32_t flag = MAPFLAGL(layer,bx,by);
4251 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4252 int32_t cid = MAPCOMBOL(layer,bx,by);
4253 int32_t type = combobuf[cid].type;
4254 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4255 type = cNONE;
4256 //zprint("cid is: %d\n", cid);
4257 //zprint("type is: %d\n", type);
4258 int32_t i = (bx>>4) + by;
4259
4260 if(i > 175)
4261 return;
4262
4263 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4264 {
4265 return;
4266 //ignorescreen = true;
4267 //zprint("ignoring\n");
4268 }
4269
4270 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4271
4272 {
4273 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4274 if(isCuttableNextType(type) || isCuttableNextType(type))
4275 {
4276 FFCore.tempScreens[layer]->data[i]++;
4277 }
4278 else
4279 {
4280 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4281 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4282 FFCore.tempScreens[layer]->sflag[i] = 0;
4283 }
4284 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4285 {
4286 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4287 sfx(tmpscr->secretsfx);
4288 }
4289 else if(isCuttableItemType(type))
4290 {
4291 int32_t it = -1;
4292 int32_t thedropset = -1;
4293
4294 if ( (combobuf[cid].usrflags&cflag2) )
4295 {
4296 if(combobuf[cid].usrflags&cflag11)
4297 it = combobuf[cid].attribytes[1];
4298 else
4299 {
4300 it = select_dropitem(combobuf[cid].attribytes[1]);
4301 thedropset = combobuf[cid].attribytes[1];
4302 }
4303 }
4304 else
4305 {
4306 it = select_dropitem(12);
4307 thedropset = 12;
4308 }
4309
4310 if(it!=-1)
4311 {
4312 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4313 itm->from_dropset = thedropset;
4314 items.add(itm);
4315 }
4316 }
4317
4318 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4319
4320 if(get_bit(quest_rules,qr_MORESOUNDS))
4321 {
4322 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4323 {
4324 if (combobuf[cid].usrflags&cflag3)
4325 {
4326 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4327 }
4328 }
4329 else
4330 {
4331 if (combobuf[cid].usrflags&cflag3)
4332 {
4333 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4334 }
4335 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4336 }
4337 }
4338
4339 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4340 if(decotype > 3) decotype = 0;
4341 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4342 switch(decotype)
4343 {
4344 case -2: break; //nothing
4345 case -1:
4346 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4347 break;
4348 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4349 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4350 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4351 }
4352
4353 }
4354
4355 183336 }
4356
4357 91668 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4358 {
4359 /*
4360 int32_t par_item = w->parentitem;
4361 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4362 int32_t usewpn = -1;
4363 if ( par_item > -1 )
4364 {
4365 usewpn = itemsbuf[par_item].useweapon;
4366 }
4367 else if ( par_item == -1 && w->ScriptGenerated )
4368 {
4369 usewpn = w->useweapon;
4370 }
4371 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4372 */
4373
4374
4375 //keep things inside the screen boundaries
4376 91668 bx=vbound(bx, 0, 255);
4377 91668 by=vbound(by, 0, 176);
4378 91668 int32_t fx=vbound(bx, 0, 255);
4379 91668 int32_t fy=vbound(by, 0, 176);
4380 91668 int32_t cid = MAPCOMBO(bx,by);
4381
4382 //find out which combo row/column the coordinates are in
4383 91668 bx &= 0xF0;
4384 91668 by &= 0xF0;
4385
4386 91668 int32_t type = COMBOTYPE(bx,by);
4387 91668 int32_t type2 = FFCOMBOTYPE(fx,fy);
4388 91668 int32_t flag = MAPFLAG(bx,by);
4389 91668 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4390 91668 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4391
1/2
✓ Branch 0 taken 91668 times.
✗ Branch 1 not taken.
91668 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4392 type = cNONE;
4393 91668 byte dontignore = 0;
4394 91668 byte dontignoreffc = 0;
4395
4396
3/4
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 91013 times.
✓ Branch 2 taken 655 times.
✗ Branch 3 not taken.
91668 if (isCuttableType(type) && MatchComboTrigger(w, combobuf, cid))
4397 {
4398 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4399 dontignore = 1;
4400 }
4401
4402 /*to-do, ffcs
4403 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4404 {
4405 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4406 dontignoreffc = 1;
4407 }*/
4408
2/4
✓ Branch 0 taken 91668 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91668 times.
✗ Branch 3 not taken.
91668 if(w->useweapon != wSword && !dontignore) return;
4409
4410
4411 int32_t i = (bx>>4) + by;
4412 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4413
4414 if(i > 175)
4415 return;
4416
4417 bool ignorescreen=false;
4418 bool ignoreffc=false;
4419
4420 if(get_bit(w->wscreengrid, i) != 0)
4421 {
4422 ignorescreen = true; dontignore = 0;
4423 }
4424
4425 int32_t current_ffcombo = getFFCAt(fx,fy);
4426
4427 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4428 {
4429 ignoreffc = true;
4430 }
4431 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4432 type2 = cNONE;
4433 if(!isCuttableType(type) &&
4434 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4435 {
4436 ignorescreen = true;
4437 }
4438
4439 if(!isCuttableType(type2) &&
4440 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4441 {
4442 ignoreffc = true;
4443 }
4444
4445 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4446
4447 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4448 byte skipsecrets = 0;
4449 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4450 {
4451 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
4452 {
4453 skipsecrets = 0;
4454 }
4455 else skipsecrets = 1;
4456 }
4457 if((!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4458 {
4459 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4460 {
4461 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4462 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4463 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4464 }
4465 else if(flag == mfARMOS_SECRET)
4466 {
4467 s->data[i] = s->secretcombo[sSTAIRS];
4468 s->cset[i] = s->secretcset[sSTAIRS];
4469 s->sflag[i] = s->secretflag[sSTAIRS];
4470 sfx(tmpscr->secretsfx);
4471 }
4472 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4473 {
4474 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4475 {
4476 findentrance(bx,by,mfSWORD+i2,true);
4477 }
4478
4479 findentrance(bx,by,mfSTRIKE,true);
4480 }
4481 else if(((flag2 >= 16)&&(flag2 <= 31)))
4482 {
4483 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4484 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4485 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4486 }
4487 else if(flag2 == mfARMOS_SECRET)
4488 {
4489 s->data[i] = s->secretcombo[sSTAIRS];
4490 s->cset[i] = s->secretcset[sSTAIRS];
4491 s->sflag[i] = s->secretflag[sSTAIRS];
4492 sfx(tmpscr->secretsfx);
4493 }
4494 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4495 {
4496 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4497 {
4498 findentrance(bx,by,mfSWORD+i2,true);
4499 }
4500
4501 findentrance(bx,by,mfSTRIKE,true);
4502 }
4503 else
4504 {
4505 if(isCuttableNextType(type))
4506 {
4507 s->data[i]++;
4508 }
4509 else
4510 {
4511 s->data[i] = s->undercombo;
4512 s->cset[i] = s->undercset;
4513 s->sflag[i] = 0;
4514 }
4515
4516 //pausenow=true;
4517 }
4518 }
4519 else if(skipsecrets && (!ignorescreen || dontignore))
4520 {
4521 if(isCuttableNextType(type))
4522 {
4523 s->data[i]++;
4524 }
4525 else
4526 {
4527 s->data[i] = s->undercombo;
4528 s->cset[i] = s->undercset;
4529 s->sflag[i] = 0;
4530 }
4531 }
4532
4533 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4534 {
4535 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4536 {
4537 findentrance(bx,by,mfSWORD+i2,true);
4538 }
4539
4540 findentrance(fx,fy,mfSTRIKE,true);
4541 }
4542 else if(!ignoreffc)
4543 {
4544 if(isCuttableNextType(type2))
4545 {
4546 s->ffcs[current_ffcombo].incData(1);
4547 }
4548 else
4549 {
4550 s->ffcs[current_ffcombo].setData(s->undercombo);
4551 s->ffcs[current_ffcombo].cset = s->undercset;
4552 }
4553 }
4554
4555 if(!ignorescreen || dontignore)
4556 {
4557 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4558
4559 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4560 {
4561 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4562 sfx(tmpscr->secretsfx);
4563 }
4564 else if(isCuttableItemType(type))
4565 {
4566 int32_t it = -1;
4567 int32_t thedropset = -1;
4568 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4569 {
4570 if ( combobuf[cid].usrflags&cflag11 )
4571 {
4572 it = combobuf[cid].attribytes[1];
4573 }
4574 else
4575 {
4576 it = select_dropitem(combobuf[cid].attribytes[1]);
4577 thedropset = combobuf[cid].attribytes[1];
4578 }
4579 }
4580 else
4581 {
4582 it = select_dropitem(12);
4583 thedropset = 12;
4584 }
4585
4586 if(it!=-1)
4587 {
4588 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4589 itm->from_dropset = thedropset;
4590 items.add(itm);
4591 }
4592 }
4593
4594
4595 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4596
4597 if(get_bit(quest_rules,qr_MORESOUNDS))
4598 {
4599 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4600 {
4601 if (combobuf[cid].usrflags&cflag3)
4602 {
4603 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4604 }
4605 }
4606 else
4607 {
4608 if (combobuf[cid].usrflags&cflag3)
4609 {
4610 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4611 }
4612 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4613 }
4614 }
4615
4616 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4617 if(decotype > 3) decotype = 0;
4618 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4619 switch(decotype)
4620 {
4621 case -2: break; //nothing
4622 case -1:
4623 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4624 break;
4625 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4626 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4627 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4628 }
4629 }
4630
4631 if(!ignoreffc)
4632 {
4633 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4634
4635 if(isCuttableItemType(type2))
4636 {
4637 int32_t it=-1;
4638 int32_t thedropset=-1;
4639 if ( (combobuf[cid].usrflags&cflag2) )
4640 {
4641 if(combobuf[cid].usrflags&cflag11)
4642 it = combobuf[cid].attribytes[1];
4643 else
4644 {
4645 it = select_dropitem(combobuf[cid].attribytes[1]);
4646 thedropset = combobuf[cid].attribytes[1];
4647 }
4648 }
4649 else
4650 {
4651 int32_t r=zc_oldrand()%100;
4652
4653 if(r<15)
4654 {
4655 it=iHeart; // 15%
4656 }
4657 else if(r<35)
4658 {
4659 it=iRupy; // 20%
4660 }
4661 }
4662
4663 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4664 {
4665 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4666 itm->from_dropset = thedropset;
4667 items.add(itm);
4668 }
4669 }
4670
4671 if(get_bit(quest_rules,qr_MORESOUNDS))
4672 {
4673 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4674 {
4675 if (combobuf[cid].usrflags&cflag3)
4676 {
4677 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4678 }
4679 }
4680 else
4681 {
4682 if (combobuf[cid].usrflags&cflag3)
4683 {
4684 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4685 }
4686 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4687 }
4688 }
4689
4690 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4691 if(decotype > 3) decotype = 0;
4692 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4693 switch(decotype)
4694 {
4695 case -2: break; //nothing
4696 case -1:
4697 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4698 break;
4699 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4700 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4701 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4702 }
4703 }
4704 91668 }
4705
4706 91668 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4707 {
4708 /*
4709 int32_t par_item = w->parentitem;
4710 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4711 int32_t usewpn = -1;
4712 if ( par_item > -1 )
4713 {
4714 usewpn = itemsbuf[par_item].useweapon;
4715 }
4716 else if ( par_item == -1 && w->ScriptGenerated )
4717 {
4718 usewpn = w->useweapon;
4719 }
4720 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4721 */
4722
4723 91668 byte dontignore = 0;
4724 91668 byte dontignoreffc = 0;
4725
4726
4727
4728
4729
4730 //keep things inside the screen boundaries
4731 91668 bx=vbound(bx, 0, 255);
4732 91668 by=vbound(by, 0, 176);
4733 91668 int32_t fx=vbound(bx, 0, 255);
4734 91668 int32_t fy=vbound(by, 0, 176);
4735 91668 int32_t cid = MAPCOMBO(bx,by);
4736
4737 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4738
2/4
✓ Branch 0 taken 91668 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 91668 times.
91668 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf, cid)) return;
4739 if ( MatchComboTrigger (w, combobuf, cid) ) dontignore = 1;
4740
4741 //first things first
4742 if(z>8||fakez>8) return;
4743
4744 //find out which combo row/column the coordinates are in
4745 bx &= 0xF0;
4746 by &= 0xF0;
4747
4748 int32_t flag = MAPFLAG(bx,by);
4749 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4750 int32_t flag3=0;
4751 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4752 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4753 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4754 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4755
4756 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4757 flag3=mfWAND;
4758
4759 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4760 flag3=mfSTRIKE;
4761
4762 int32_t i = (bx>>4) + by;
4763
4764 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4765 return;
4766
4767 if(i > 175)
4768 return;
4769
4770 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4771
4772 //findentrance(bx,by,mfWAND,true);
4773 //findentrance(bx,by,mfSTRIKE,true);
4774 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4775 {
4776 if(flag3==mfWAND||flag3==mfSTRIKE)
4777 {
4778 findentrance(fx,fy,mfWAND,true);
4779 findentrance(fx,fy,mfSTRIKE,true);
4780 }
4781 }
4782
4783 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4784
4785 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4786 91668 }
4787
4788 91668 void HeroClass::check_pound_block2(int32_t bx, int32_t by, weapon *w)
4789 {
4790 /*
4791 int32_t par_item = w->parentitem;
4792 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
4793 int32_t usewpn = -1;
4794 if ( par_item > -1 )
4795 {
4796 usewpn = itemsbuf[par_item].useweapon;
4797 }
4798 else if ( par_item == -1 && w->ScriptGenerated )
4799 {
4800 usewpn = w->useweapon;
4801 }
4802 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
4803 */
4804 //keep things inside the screen boundaries
4805 91668 bx=vbound(bx, 0, 255);
4806 91668 by=vbound(by, 0, 176);
4807 91668 int32_t fx=vbound(bx, 0, 255);
4808 91668 int32_t fy=vbound(by, 0, 176);
4809 91668 int32_t cid = MAPCOMBO(bx,by);
4810 91668 byte dontignore = MatchComboTrigger (w, combobuf, cid);
4811
2/4
✓ Branch 0 taken 91668 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 91668 times.
91668 if(w->useweapon != wHammer && !dontignore ) return;
4812
4813
4814
4815
4816 //first things first
4817 if(z>8||fakez>8) return;
4818
4819 //find out which combo row/column the coordinates are in
4820 bx &= 0xF0;
4821 by &= 0xF0;
4822
4823 int32_t type = COMBOTYPE(bx,by);
4824 int32_t type2 = FFCOMBOTYPE(fx,fy);
4825 int32_t flag = MAPFLAG(bx,by);
4826 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4827 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4828 int32_t i = (bx>>4) + by;
4829 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4830
4831 if(i > 175)
4832 return;
4833
4834 bool ignorescreen=false;
4835 bool ignoreffc=false;
4836 bool pound=false;
4837
4838 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4839 type = cNONE;
4840 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
4841 ignorescreen = true; // Affect only FFCs
4842
4843 if(get_bit(w->wscreengrid, i) != 0)
4844 {
4845 ignorescreen = true; dontignore = 0;
4846 }
4847
4848 int32_t current_ffcombo = getFFCAt(fx,fy);
4849
4850 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4851 ignoreffc = true;
4852 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4853 type2 = cNONE;
4854 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
4855 ignoreffc = true;
4856
4857 if(ignorescreen && ignoreffc) // Nothing to do.
4858 return;
4859
4860 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4861
4862 if(!ignorescreen || dontignore)
4863 {
4864 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
4865 {
4866 findentrance(bx,by,mfHAMMER,true);
4867 findentrance(bx,by,mfSTRIKE,true);
4868 }
4869 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
4870 {
4871 findentrance(bx,by,mfHAMMER,true);
4872 findentrance(bx,by,mfSTRIKE,true);
4873 }
4874 else if((flag >= 16)&&(flag <= 31))
4875 {
4876 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4877 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4878 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4879 }
4880 else if(flag == mfARMOS_SECRET)
4881 {
4882 s->data[i] = s->secretcombo[sSTAIRS];
4883 s->cset[i] = s->secretcset[sSTAIRS];
4884 s->sflag[i] = s->secretflag[sSTAIRS];
4885 sfx(tmpscr->secretsfx);
4886 }
4887 else if((flag2 >= 16)&&(flag2 <= 31))
4888 {
4889 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4890 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4891 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4892 }
4893 else if(flag2 == mfARMOS_SECRET)
4894 {
4895 s->data[i] = s->secretcombo[sSTAIRS];
4896 s->cset[i] = s->secretcset[sSTAIRS];
4897 s->sflag[i] = s->secretflag[sSTAIRS];
4898 sfx(tmpscr->secretsfx);
4899 }
4900 else pound = true;
4901 }
4902
4903 if(!ignoreffc)
4904 {
4905 if(flag3==mfHAMMER||flag3==mfSTRIKE)
4906 {
4907 findentrance(fx,fy,mfHAMMER,true);
4908 findentrance(fx,fy,mfSTRIKE,true);
4909 }
4910 else
4911 {
4912 s->ffcs[current_ffcombo].incData(1);
4913 }
4914 }
4915
4916 if(!ignorescreen || dontignore)
4917 {
4918 if(pound)
4919 s->data[i]+=1;
4920
4921 set_bit(w->wscreengrid,i,1);
4922
4923 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4924 {
4925 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4926 sfx(tmpscr->secretsfx);
4927 }
4928
4929 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4930 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4931
4932 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4933 }
4934
4935 if(!ignoreffc)
4936 {
4937 set_bit(ffcgrid,current_ffcombo,1);
4938
4939 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4940 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4941 }
4942
4943 return;
4944 91668 }
4945
4946 void HeroClass::check_slash_block(weapon *w)
4947 {
4948 //first things
4949
4950 int32_t par_item = w->parentitem;
4951 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4952 int32_t usewpn = -1;
4953 if ( par_item > -1 )
4954 {
4955 usewpn = itemsbuf[par_item].useweapon;
4956 }
4957 else if ( par_item == -1 && w->ScriptGenerated )
4958 {
4959 usewpn = w->useweapon;
4960 }
4961 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4962 if(usewpn != wSword) return;
4963
4964
4965 int32_t bx = 0, by = 0;
4966 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
4967 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
4968 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
4969 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
4970 //keep things inside the screen boundaries
4971 bx=vbound(bx, 0, 255);
4972 by=vbound(by, 0, 176);
4973 int32_t fx=vbound(bx, 0, 255);
4974 int32_t fy=vbound(by, 0, 176);
4975
4976 int32_t cid = MAPCOMBO(bx,by);
4977
4978 //find out which combo row/column the coordinates are in
4979 bx &= 0xF0;
4980 by &= 0xF0;
4981
4982 int32_t type = COMBOTYPE(bx,by);
4983 int32_t type2 = FFCOMBOTYPE(fx,fy);
4984 int32_t flag = MAPFLAG(bx,by);
4985 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4986 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4987 int32_t i = (bx>>4) + by;
4988
4989 if(i > 175)
4990 {
4991 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
4992 return;
4993 }
4994
4995 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4996 type = cNONE;
4997 bool ignorescreen=false;
4998 bool ignoreffc=false;
4999
5000 if(get_bit(screengrid, i) != 0)
5001 {
5002 ignorescreen = true;
5003 }
5004
5005 int32_t current_ffcombo = getFFCAt(fx,fy);
5006
5007 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5008 {
5009 ignoreffc = true;
5010 }
5011 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
5012 type2 = cNONE;
5013 if(!isCuttableType(type) &&
5014 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5015 {
5016 ignorescreen = true;
5017 }
5018
5019 if(!isCuttableType(type2) &&
5020 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5021 {
5022 ignoreffc = true;
5023 }
5024
5025 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5026
5027 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5028
5029 if(!ignorescreen)
5030 {
5031 if((flag >= 16)&&(flag <= 31))
5032 {
5033 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5034 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5035 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5036 }
5037 else if(flag == mfARMOS_SECRET)
5038 {
5039 s->data[i] = s->secretcombo[sSTAIRS];
5040 s->cset[i] = s->secretcset[sSTAIRS];
5041 s->sflag[i] = s->secretflag[sSTAIRS];
5042 sfx(tmpscr->secretsfx);
5043 }
5044 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5045 {
5046 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5047 {
5048 findentrance(bx,by,mfSWORD+i2,true);
5049 }
5050
5051 findentrance(bx,by,mfSTRIKE,true);
5052 }
5053 else if(((flag2 >= 16)&&(flag2 <= 31)))
5054 {
5055 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5056 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5057 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5058 }
5059 else if(flag2 == mfARMOS_SECRET)
5060 {
5061 s->data[i] = s->secretcombo[sSTAIRS];
5062 s->cset[i] = s->secretcset[sSTAIRS];
5063 s->sflag[i] = s->secretflag[sSTAIRS];
5064 sfx(tmpscr->secretsfx);
5065 }
5066 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5067 {
5068 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5069 {
5070 findentrance(bx,by,mfSWORD+i2,true);
5071 }
5072
5073 findentrance(bx,by,mfSTRIKE,true);
5074 }
5075 else
5076 {
5077 if(isCuttableNextType(type))
5078 {
5079 s->data[i]++;
5080 }
5081 else
5082 {
5083 s->data[i] = s->undercombo;
5084 s->cset[i] = s->undercset;
5085 s->sflag[i] = 0;
5086 }
5087
5088 //pausenow=true;
5089 }
5090 }
5091
5092 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5093 {
5094 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5095 {
5096 findentrance(bx,by,mfSWORD+i2,true);
5097 }
5098
5099 findentrance(fx,fy,mfSTRIKE,true);
5100 }
5101 else if(!ignoreffc)
5102 {
5103 if(isCuttableNextType(type2))
5104 {
5105 s->ffcs[current_ffcombo].incData(1);
5106 }
5107 else
5108 {
5109 s->ffcs[current_ffcombo].setData(s->undercombo);
5110 s->ffcs[current_ffcombo].cset = s->undercset;
5111 }
5112 }
5113
5114 if(!ignorescreen)
5115 {
5116 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5117
5118 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5119 {
5120 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5121 sfx(tmpscr->secretsfx);
5122 }
5123 else if(isCuttableItemType(type))
5124 {
5125 int32_t it = -1;
5126 int32_t thedropset = -1;
5127 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5128 {
5129 if ( combobuf[cid].usrflags&cflag11 )
5130 {
5131 it = combobuf[cid].attribytes[1];
5132 }
5133 else
5134 {
5135 it = select_dropitem(combobuf[cid].attribytes[1]);
5136 thedropset = combobuf[cid].attribytes[1];
5137 }
5138 }
5139 else
5140 {
5141 it = select_dropitem(12);
5142 thedropset = 12;
5143 }
5144
5145 if(it!=-1)
5146 {
5147 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5148 itm->from_dropset = thedropset;
5149 items.add(itm);
5150 }
5151 }
5152
5153 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5154
5155 if(get_bit(quest_rules,qr_MORESOUNDS))
5156 {
5157 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5158 {
5159 if (combobuf[cid].usrflags&cflag3)
5160 {
5161 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5162 }
5163 }
5164 else
5165 {
5166 if (combobuf[cid].usrflags&cflag3)
5167 {
5168 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5169 }
5170 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5171 }
5172 }
5173
5174 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5175 if(decotype > 3) decotype = 0;
5176 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5177 switch(decotype)
5178 {
5179 case -2: break; //nothing
5180 case -1:
5181 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5182 break;
5183 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5184 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5185 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5186 }
5187 }
5188
5189 if(!ignoreffc)
5190 {
5191 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5192
5193 if(isCuttableItemType(type2))
5194 {
5195 int32_t it=-1;
5196 int32_t thedropset = -1;
5197 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5198 {
5199 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5200 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5201 else
5202 {
5203 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5204 it = select_dropitem(thedropset);
5205 }
5206 }
5207 else
5208 {
5209 it = select_dropitem(12);
5210 thedropset = 12;
5211 }
5212
5213 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5214 {
5215 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5216 itm->from_dropset = thedropset;
5217 items.add(itm);
5218 }
5219 }
5220
5221 if(get_bit(quest_rules,qr_MORESOUNDS))
5222 {
5223 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5224 {
5225 if (combobuf[cid].usrflags&cflag3)
5226 {
5227 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5228 }
5229 }
5230 else
5231 {
5232 if (combobuf[cid].usrflags&cflag3)
5233 {
5234 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5235 }
5236 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5237 }
5238 }
5239
5240 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5241 if(decotype > 3) decotype = 0;
5242 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5243 switch(decotype)
5244 {
5245 case -2: break; //nothing
5246 case -1:
5247 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5248 break;
5249 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5250 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5251 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5252 }
5253 }
5254 }
5255
5256 //TODO: Boomerang that cuts bushes. -L
5257 /*void HeroClass::slash_bush()
5258 {
5259
5260 }*/
5261
5262 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5263 {
5264 //keep things inside the screen boundaries
5265 bx=vbound(bx, 0, 255);
5266 by=vbound(by, 0, 176);
5267 int32_t fx=vbound(bx, 0, 255);
5268 int32_t fy=vbound(by, 0, 176);
5269 int32_t cid = MAPCOMBO(bx,by);
5270
5271 //first things first
5272 if(z>8||fakez>8) return;
5273
5274 //find out which combo row/column the coordinates are in
5275 bx &= 0xF0;
5276 by &= 0xF0;
5277
5278 int32_t flag = MAPFLAG(bx,by);
5279 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5280 int32_t flag3=0;
5281 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5282 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5283 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5284 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5285
5286 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5287 flag3=mfWAND;
5288
5289 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5290 flag3=mfSTRIKE;
5291
5292 int32_t i = (bx>>4) + by;
5293
5294 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5295 return;
5296
5297 if(i > 175)
5298 return;
5299
5300 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5301
5302 //findentrance(bx,by,mfWAND,true);
5303 //findentrance(bx,by,mfSTRIKE,true);
5304 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5305 {
5306 if(flag3==mfWAND||flag3==mfSTRIKE)
5307 {
5308 findentrance(fx,fy,mfWAND,true);
5309 findentrance(fx,fy,mfSTRIKE,true);
5310 }
5311 }
5312
5313 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5314 }
5315
5316 void HeroClass::check_pound_block(int32_t bx, int32_t by)
5317 {
5318 //keep things inside the screen boundaries
5319 bx=vbound(bx, 0, 255);
5320 by=vbound(by, 0, 176);
5321 int32_t fx=vbound(bx, 0, 255);
5322 int32_t fy=vbound(by, 0, 176);
5323 int32_t cid = MAPCOMBO(bx,by);
5324
5325 //first things first
5326 if(z>8||fakez>8) return;
5327
5328 //find out which combo row/column the coordinates are in
5329 bx &= 0xF0;
5330 by &= 0xF0;
5331
5332 int32_t type = COMBOTYPE(bx,by);
5333 int32_t type2 = FFCOMBOTYPE(fx,fy);
5334 int32_t flag = MAPFLAG(bx,by);
5335 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5336 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5337 int32_t i = (bx>>4) + by;
5338
5339 if(i > 175)
5340 return;
5341
5342 bool ignorescreen=false;
5343 bool ignoreffc=false;
5344 bool pound=false;
5345
5346 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5347 ignorescreen = true; // Affect only FFCs
5348
5349 if(get_bit(screengrid, i) != 0)
5350 ignorescreen = true;
5351
5352 int32_t current_ffcombo = getFFCAt(fx,fy);
5353
5354 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5355 ignoreffc = true;
5356
5357 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5358 ignoreffc = true;
5359
5360 if(ignorescreen && ignoreffc) // Nothing to do.
5361 return;
5362
5363 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5364
5365 if(!ignorescreen)
5366 {
5367 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5368 {
5369 findentrance(bx,by,mfHAMMER,true);
5370 findentrance(bx,by,mfSTRIKE,true);
5371 }
5372 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5373 {
5374 findentrance(bx,by,mfHAMMER,true);
5375 findentrance(bx,by,mfSTRIKE,true);
5376 }
5377 else if((flag >= 16)&&(flag <= 31))
5378 {
5379 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5380 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5381 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5382 }
5383 else if(flag == mfARMOS_SECRET)
5384 {
5385 s->data[i] = s->secretcombo[sSTAIRS];
5386 s->cset[i] = s->secretcset[sSTAIRS];
5387 s->sflag[i] = s->secretflag[sSTAIRS];
5388 sfx(tmpscr->secretsfx);
5389 }
5390 else if((flag2 >= 16)&&(flag2 <= 31))
5391 {
5392 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5393 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5394 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5395 }
5396 else if(flag2 == mfARMOS_SECRET)
5397 {
5398 s->data[i] = s->secretcombo[sSTAIRS];
5399 s->cset[i] = s->secretcset[sSTAIRS];
5400 s->sflag[i] = s->secretflag[sSTAIRS];
5401 sfx(tmpscr->secretsfx);
5402 }
5403 else pound = true;
5404 }
5405
5406 if(!ignoreffc)
5407 {
5408 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5409 {
5410 findentrance(fx,fy,mfHAMMER,true);
5411 findentrance(fx,fy,mfSTRIKE,true);
5412 }
5413 else
5414 {
5415 s->ffcs[current_ffcombo].incData(1);
5416 }
5417 }
5418
5419 if(!ignorescreen)
5420 {
5421 if(pound)
5422 s->data[i]+=1;
5423
5424 set_bit(screengrid,i,1);
5425
5426 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5427 {
5428 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5429 sfx(tmpscr->secretsfx);
5430 }
5431
5432 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5433 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5434
5435 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5436 }
5437
5438 if(!ignoreffc)
5439 {
5440 set_bit(ffcgrid,current_ffcombo,1);
5441
5442 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5443 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5444 }
5445
5446 return;
5447 }
5448
5449
5450 void HeroClass::check_wand_block(weapon *w)
5451 {
5452
5453 int32_t par_item = w->parentitem;
5454 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5455 int32_t usewpn = -1;
5456 if ( par_item > -1 )
5457 {
5458 usewpn = itemsbuf[par_item].useweapon;
5459 }
5460 else if ( par_item == -1 && w->ScriptGenerated )
5461 {
5462 usewpn = w->useweapon;
5463 }
5464 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5465 if(usewpn != wWand) return;
5466
5467
5468 int32_t bx = 0, by = 0;
5469 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5470 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5471
5472 //keep things inside the screen boundaries
5473 bx=vbound(bx, 0, 255);
5474 by=vbound(by, 0, 176);
5475 int32_t fx=vbound(bx, 0, 255);
5476 int32_t fy=vbound(by, 0, 176);
5477 int32_t cid = MAPCOMBO(bx,by);
5478 //first things first
5479 if(z>8||fakez>8) return;
5480
5481 //find out which combo row/column the coordinates are in
5482 bx &= 0xF0;
5483 by &= 0xF0;
5484
5485 int32_t flag = MAPFLAG(bx,by);
5486 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5487 int32_t flag3=0;
5488 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5489 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5490 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5491 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5492
5493 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5494 flag3=mfWAND;
5495
5496 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5497 flag3=mfSTRIKE;
5498
5499 int32_t i = (bx>>4) + by;
5500
5501 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5502 return;
5503
5504 if(i > 175)
5505 return;
5506
5507 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5508
5509 //findentrance(bx,by,mfWAND,true);
5510 //findentrance(bx,by,mfSTRIKE,true);
5511 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5512 {
5513 if(flag3==mfWAND||flag3==mfSTRIKE)
5514 {
5515 findentrance(fx,fy,mfWAND,true);
5516 findentrance(fx,fy,mfSTRIKE,true);
5517 }
5518 }
5519
5520 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5521 }
5522
5523 void HeroClass::check_pound_block(weapon *w)
5524 {
5525
5526 int32_t par_item = w->parentitem;
5527 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
5528 int32_t usewpn = -1;
5529 if ( par_item > -1 )
5530 {
5531 usewpn = itemsbuf[par_item].useweapon;
5532 }
5533 else if ( par_item == -1 && w->ScriptGenerated )
5534 {
5535 usewpn = w->useweapon;
5536 }
5537 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
5538 if(usewpn != wHammer) return;
5539
5540
5541 int32_t bx = 0, by = 0;
5542 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5543 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5544 //keep things inside the screen boundaries
5545 bx=vbound(bx, 0, 255);
5546 by=vbound(by, 0, 176);
5547 int32_t fx=vbound(bx, 0, 255);
5548 int32_t fy=vbound(by, 0, 176);
5549 int32_t cid = MAPCOMBO(bx,by);
5550 //first things first
5551 if(z>8||fakez>8) return;
5552
5553 //find out which combo row/column the coordinates are in
5554 bx &= 0xF0;
5555 by &= 0xF0;
5556
5557 int32_t type = COMBOTYPE(bx,by);
5558 int32_t type2 = FFCOMBOTYPE(fx,fy);
5559 int32_t flag = MAPFLAG(bx,by);
5560 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5561 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5562 int32_t i = (bx>>4) + by;
5563
5564 if(i > 175)
5565 return;
5566
5567 bool ignorescreen=false;
5568 bool ignoreffc=false;
5569 bool pound=false;
5570
5571 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5572 ignorescreen = true; // Affect only FFCs
5573
5574 if(get_bit(screengrid, i) != 0)
5575 ignorescreen = true;
5576
5577 int32_t current_ffcombo = getFFCAt(fx,fy);
5578
5579 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5580 ignoreffc = true;
5581
5582 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5583 ignoreffc = true;
5584
5585 if(ignorescreen && ignoreffc) // Nothing to do.
5586 return;
5587
5588 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5589
5590 if(!ignorescreen)
5591 {
5592 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5593 {
5594 findentrance(bx,by,mfHAMMER,true);
5595 findentrance(bx,by,mfSTRIKE,true);
5596 }
5597 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5598 {
5599 findentrance(bx,by,mfHAMMER,true);
5600 findentrance(bx,by,mfSTRIKE,true);
5601 }
5602 else if((flag >= 16)&&(flag <= 31))
5603 {
5604 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5605 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5606 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5607 }
5608 else if(flag == mfARMOS_SECRET)
5609 {
5610 s->data[i] = s->secretcombo[sSTAIRS];
5611 s->cset[i] = s->secretcset[sSTAIRS];
5612 s->sflag[i] = s->secretflag[sSTAIRS];
5613 sfx(tmpscr->secretsfx);
5614 }
5615 else if((flag2 >= 16)&&(flag2 <= 31))
5616 {
5617 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5618 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5619 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5620 }
5621 else if(flag2 == mfARMOS_SECRET)
5622 {
5623 s->data[i] = s->secretcombo[sSTAIRS];
5624 s->cset[i] = s->secretcset[sSTAIRS];
5625 s->sflag[i] = s->secretflag[sSTAIRS];
5626 sfx(tmpscr->secretsfx);
5627 }
5628 else pound = true;
5629 }
5630
5631 if(!ignoreffc)
5632 {
5633 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5634 {
5635 findentrance(fx,fy,mfHAMMER,true);
5636 findentrance(fx,fy,mfSTRIKE,true);
5637 }
5638 else
5639 {
5640 s->ffcs[current_ffcombo].incData(1);
5641 }
5642 }
5643
5644 if(!ignorescreen)
5645 {
5646 if(pound)
5647 s->data[i]+=1;
5648
5649 set_bit(screengrid,i,1);
5650
5651 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5652 {
5653 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5654 sfx(tmpscr->secretsfx);
5655 }
5656
5657 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5658 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5659
5660 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5661 }
5662
5663 if(!ignoreffc)
5664 {
5665 set_bit(ffcgrid,current_ffcombo,1);
5666
5667 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5668 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5669 }
5670
5671 return;
5672 }
5673
5674 //defend results should match defence types.
5675 //RETURN VALUES:
5676 // -1 iGNORE WEAPON
5677 // 0 No effects
5678 // 1 Effects, weapon is not ignored or removed
5679 20 int32_t HeroClass::defend(weapon *w)
5680 {
5681 20 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5682
1/25
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
20 switch(def)
5683 {
5684 20 case edNORMAL: return 1;
5685 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5686 {
5687 w->power *= 0.5;
5688 return 1;
5689 }
5690 case edQUARTDAMAGE:
5691 {
5692 w->power *= 0.25;
5693 return 1;
5694 }
5695 case edSTUNONLY:
5696 {
5697 setStunClock(120);
5698 return 1;
5699 }
5700 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5701 {
5702 if (w->power > 0)
5703 {
5704 setStunClock(120);
5705 return 1;
5706 }
5707 else
5708 {
5709 sfx(WAV_CHINK,pan(int32_t(x)));
5710 w->dead = 0;
5711 return -1;
5712 }
5713 }
5714 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5715 {
5716 if (w->power > 0)
5717 {
5718 setStunClock(120);
5719 return 1;
5720 }
5721 else
5722 {
5723 return -1;
5724 }
5725 }
5726 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5727 {
5728 if (w->power < 1)
5729 {
5730 sfx(WAV_CHINK,pan(int32_t(x)));
5731 w->dead = 0;
5732 return -1;
5733 }
5734 else
5735 {
5736 return 1;
5737 }
5738 }
5739 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5740 {
5741 if (w->power < 2)
5742 {
5743 sfx(WAV_CHINK,pan(int32_t(x)));
5744 w->dead = 0;
5745 return -1;
5746 }
5747 else
5748 {
5749 return 1;
5750 }
5751 }
5752 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5753 {
5754 if (w->power < 4)
5755 {
5756 sfx(WAV_CHINK,pan(int32_t(x)));
5757 w->dead = 0;
5758 return -1;
5759 }
5760 else
5761 {
5762 return 1;
5763 }
5764 }
5765 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5766 {
5767 if (w->power < 6)
5768 {
5769 sfx(WAV_CHINK,pan(int32_t(x)));
5770 w->dead = 0;
5771 return -1;
5772 }
5773 else
5774 {
5775 return 1;
5776 }
5777 }
5778 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5779 {
5780 if (w->power < 8)
5781 {
5782 sfx(WAV_CHINK,pan(int32_t(x)));
5783 w->dead = 0;
5784 return -1;
5785 }
5786 else
5787 {
5788 return 1;
5789 }
5790 }
5791 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5792 {
5793 sfx(WAV_CHINK,pan(int32_t(x)));
5794 w->dead = 0;
5795 return -1;
5796 }
5797 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5798 {
5799 if (w->power < 1)
5800 {
5801 return -1;
5802 }
5803 else return 1;
5804 }
5805 case edIGNORE: // : IMPLEMENTED : Do Nothing
5806 {
5807 return -1;
5808 }
5809 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5810 {
5811 game->set_life(0);
5812 return 1;
5813 }
5814 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5815 {
5816 if (w->power < 10)
5817 {
5818 sfx(WAV_CHINK,pan(int32_t(x)));
5819 w->dead = 0;
5820 return -1;
5821 }
5822 else
5823 {
5824 return 1;
5825 }
5826 }
5827 case ed2x: // : IMPLEMENTED : Double damage.
5828 {
5829 w->power *= 2;
5830 return 1;
5831 }
5832 case ed3x: // : IMPLEMENTED : Triple Damage.
5833 {
5834 w->power *= 3;
5835 return 1;
5836 }
5837 case ed4x: // : IMPLEMENTED : 4x damage.
5838 {
5839 w->power *= 4;
5840 return 1;
5841 }
5842 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5843 {
5844 //sfx(WAV_HEAL,pan(int32_t(x)));
5845 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5846 w->dead = 0;
5847 return -1;
5848 }
5849
5850 case edFREEZE: return 1; //Not IMPLEMENTED
5851
5852 case edLEVELDAMAGE: //Damage * item level
5853 {
5854 w->power *= w->family_level;
5855 return 1;
5856 }
5857 case edLEVELREDUCTION: //Damage / item level
5858 {
5859 if ( w->family_level > 0 )
5860 {
5861 w->power /= w->family_level;
5862 }
5863 else w->power = 0;
5864 return 1;
5865 }
5866
5867 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5868 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5869 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5870 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5871
5872 //edSHOCK, //buzz blob
5873
5874
5875 case edBREAKSHIELD: //destroy the player's present shield
5876 {
5877 w->power = 0;
5878 w->dead = 0;
5879 int32_t itemid = getCurrentShield();
5880 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5881 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5882 game->set_item(itemid, false);
5883 //Remove Hero's shield
5884 return -1;
5885 }
5886
5887
5888
5889 default: return 0;
5890 }
5891 20 }
5892
5893 20 int32_t HeroClass::compareDir(int32_t other)
5894 {
5895
3/6
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
20 if(other != NORMAL_DIR(other))
5896 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5897 20 int32_t ret = 0;
5898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5899
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 10 times.
20 switch(d)
5900 {
5901 case up:
5902 {
5903
2/3
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
2 switch(X_DIR(other))
5904 {
5905 case left:
5906 ret |= CMPDIR_RIGHT;
5907 break;
5908 case right:
5909 1 ret |= CMPDIR_LEFT;
5910 1 break;
5911 }
5912
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 switch(Y_DIR(other))
5913 {
5914 case up:
5915 ret |= CMPDIR_BACK;
5916 break;
5917 case down:
5918 2 ret |= CMPDIR_FRONT;
5919 2 break;
5920 }
5921 2 break;
5922 }
5923 case down:
5924 {
5925
2/3
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
3 switch(X_DIR(other))
5926 {
5927 case left:
5928 ret |= CMPDIR_LEFT;
5929 break;
5930 case right:
5931 1 ret |= CMPDIR_RIGHT;
5932 1 break;
5933 }
5934
3/3
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
3 switch(Y_DIR(other))
5935 {
5936 case up:
5937 1 ret |= CMPDIR_FRONT;
5938 1 break;
5939 case down:
5940 1 ret |= CMPDIR_BACK;
5941 1 break;
5942 }
5943 3 break;
5944 }
5945 case left:
5946 {
5947
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
5 switch(X_DIR(other))
5948 {
5949 case left:
5950 2 ret |= CMPDIR_BACK;
5951 2 break;
5952 case right:
5953 3 ret |= CMPDIR_FRONT;
5954 3 break;
5955 }
5956
2/3
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
5 switch(Y_DIR(other))
5957 {
5958 case up:
5959 ret |= CMPDIR_LEFT;
5960 break;
5961 case down:
5962 1 ret |= CMPDIR_RIGHT;
5963 1 break;
5964 }
5965 5 break;
5966 }
5967 case right:
5968 {
5969
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 switch(X_DIR(other))
5970 {
5971 case left:
5972 10 ret |= CMPDIR_FRONT;
5973 10 break;
5974 case right:
5975 ret |= CMPDIR_BACK;
5976 break;
5977 }
5978
1/3
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
10 switch(Y_DIR(other))
5979 {
5980 case up:
5981 ret |= CMPDIR_RIGHT;
5982 break;
5983 case down:
5984 ret |= CMPDIR_LEFT;
5985 break;
5986 }
5987 10 break;
5988 }
5989 }
5990 20 return ret;
5991 20 }
5992
5993 20 bool compareShield(int32_t cmpdir, itemdata const& shield)
5994 {
5995
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5996
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(standard) //Use standard sides, either a passive shield, or a held active shield
5997 {
5998
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
20 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5999 16 return true;
6000
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
4 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
6001 return true;
6002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
6003 return true;
6004
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
4 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
6005 return true;
6006 4 }
6007 else //Active Shield that is NOT held down
6008 {
6009 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
6010 return true;
6011 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
6012 return true;
6013 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
6014 return true;
6015 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
6016 return true;
6017 }
6018 4 return false;
6019 20 }
6020
6021 61056 int32_t HeroClass::EwpnHit()
6022 {
6023
2/2
✓ Branch 0 taken 61049 times.
✓ Branch 1 taken 12507 times.
73556 for(int32_t i=0; i<Ewpns.Count(); i++)
6024 {
6025
2/2
✓ Branch 0 taken 12487 times.
✓ Branch 1 taken 20 times.
12507 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6026 {
6027 20 weapon *ew = (weapon*)(Ewpns.spr(i));
6028
6029
3/6
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
20 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6030 break;
6031
6032 20 int32_t stompid = current_item_id(itype_stompboots);
6033
6034
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
20 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6035 ((z+fakez) > (ew->z+(ew->fakez))) ||
6036 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
6037 {
6038 itemdata const& stomp = itemsbuf[stompid];
6039 bool remove = false;
6040 switch(ew->id)
6041 {
6042 case ewFireball2:
6043 case ewFireball:
6044 if(ew->type & 1) //Boss fireball
6045 {
6046 if(stomp.misc2 & (shFIREBALL2))
6047 remove = true;
6048 }
6049 else
6050 {
6051 if(stomp.misc2 & (shFIREBALL))
6052 remove = true;
6053 }
6054
6055 break;
6056
6057 case ewMagic:
6058 if((stomp.misc2 & shMAGIC))
6059 remove = true;
6060 break;
6061
6062 case ewSword:
6063 if((stomp.misc2 & shSWORD))
6064 remove = true;
6065
6066 break;
6067
6068 case ewFlame:
6069 if((stomp.misc2 & shFLAME))
6070 remove = true;
6071
6072 break;
6073
6074 case ewRock:
6075 if((stomp.misc2 & shROCK))
6076 remove = true;
6077
6078 break;
6079
6080 case ewArrow:
6081 if((stomp.misc2 & shARROW))
6082 remove = true;
6083
6084 break;
6085
6086 case ewBrang:
6087 if((stomp.misc2 & shBRANG))
6088 remove = true;
6089
6090 break;
6091
6092 default: // Just throw the script weapons in here...
6093 if(ew->id>=wScript1 && ew->id<=wScript10)
6094 {
6095 if((stomp.misc2 & shSCRIPT))
6096 remove = true;
6097 }
6098
6099 break;
6100 }
6101 if (remove)
6102 {
6103 ew->onhit(false);
6104 sfx(WAV_CHINK,pan(x.getInt()));
6105 continue;
6106 }
6107 }
6108
6109 20 int32_t defresult = defend(ew);
6110
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6111
6112
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(ew->id==ewWind)
6113 {
6114 xofs=1000;
6115 action=freeze; FFCore.setHeroAction(freeze);
6116 ew->misc=999; // in enemy wind
6117 attackclk=0;
6118 return -1;
6119 }
6120
6121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 switch(ew->id)
6122 {
6123 case ewLitBomb:
6124 case ewBomb:
6125 case ewLitSBomb:
6126 case ewSBomb:
6127 return i;
6128 }
6129
6130 20 int32_t itemid = getCurrentShield(false);
6131
3/6
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
20 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6132 20 itemdata const& shield = itemsbuf[itemid];
6133 20 auto cmpdir = compareDir(ew->dir);
6134 20 bool hitshield = compareShield(cmpdir, shield);
6135
6136
6137
11/18
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 13 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 13 times.
20 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF)
6138 {
6139 7 return i;
6140 }
6141
6142 13 paymagiccost(itemid);
6143
6144 13 bool reflect = false;
6145
6146
3/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 2 times.
13 switch(ew->id)
6147 {
6148 case ewFireball2:
6149 case ewFireball:
6150 if(ew->type & 1) //Boss fireball
6151 {
6152 if(!(shield.misc1 & (shFIREBALL2)))
6153 return i;
6154
6155 reflect = ((shield.misc2 & shFIREBALL2) != 0);
6156 }
6157 else
6158 {
6159 if(!(shield.misc1 & (shFIREBALL)))
6160 return i;
6161
6162 reflect = ((shield.misc2 & shFIREBALL) != 0);
6163 }
6164
6165 break;
6166
6167 case ewMagic:
6168 if(!(shield.misc1 & shMAGIC))
6169 return i;
6170
6171 reflect = ((shield.misc2 & shMAGIC) != 0);
6172 break;
6173
6174 case ewSword:
6175 if(!(shield.misc1 & shSWORD))
6176 return i;
6177
6178 reflect = ((shield.misc2 & shSWORD) != 0);
6179 break;
6180
6181 case ewFlame:
6182 if(!(shield.misc1 & shFLAME))
6183 return i;
6184
6185 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
6186 break;
6187
6188 case ewRock:
6189
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!(shield.misc1 & shROCK))
6190 return i;
6191
6192 9 reflect = (shield.misc2 & shROCK);
6193 9 break;
6194
6195 case ewArrow:
6196
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(shield.misc1 & shARROW))
6197 return i;
6198
6199 2 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6200 2 break;
6201
6202 case ewBrang:
6203
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(shield.misc1 & shBRANG))
6204 return i;
6205
6206 2 break;
6207
6208 default: // Just throw the script weapons in here...
6209 if(ew->id>=wScript1 && ew->id<=wScript10)
6210 {
6211 if(!(shield.misc1 & shSCRIPT))
6212 return i;
6213
6214 reflect = ((shield.misc2 & shSCRIPT) != 0);
6215 }
6216
6217 break;
6218 }
6219
6220
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(reflect && (ew->unblockable&WPNUNB_REFL))
6221 reflect = false;
6222
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6223 return i;
6224
6225 13 int32_t oldid = ew->id;
6226 13 ew->onhit(false, reflect ? 2 : 1, dir);
6227
6228
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(ew->id != oldid) // changed type from ewX to wX
6229 {
6230 // ew->power*=game->get_hero_dmgmult();
6231 Lwpns.add(ew);
6232 Ewpns.remove(ew);
6233 ew->isLWeapon = true; //Make sure this gets set everywhere!
6234 }
6235
6236
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(ew->id==wRefMagic)
6237 {
6238 ew->ignoreHero=true;
6239 ew->ignorecombo=-1;
6240 }
6241
6242 13 sfx(shield.usesound,pan(x.getInt()));
6243 13 }
6244 12500 }
6245
6246 61049 return -1;
6247 61056 }
6248
6249 61056 int32_t HeroClass::LwpnHit() //only here to check magic hits
6250 {
6251
2/2
✓ Branch 0 taken 60230 times.
✓ Branch 1 taken 21169 times.
81399 for(int32_t i=0; i<Lwpns.Count(); i++)
6252
2/2
✓ Branch 0 taken 20343 times.
✓ Branch 1 taken 826 times.
21169 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6253 {
6254 826 weapon *lw = (weapon*)(Lwpns.spr(i));
6255
6256
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 if((lw->ignoreHero)==true)
6257 break;
6258
6259
4/8
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 826 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 826 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 826 times.
826 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6260 int32_t itemid = getCurrentShield(false);
6261 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6262 itemdata const& shield = itemsbuf[itemid];
6263 auto cmpdir = compareDir(lw->dir);
6264 bool hitshield = compareShield(cmpdir, shield);
6265 bool reflect = false;
6266
6267 switch(lw->id)
6268 {
6269 case wRefFireball:
6270 if(itemid<0)
6271 return i;
6272
6273 if(lw->type & 1) //Boss fireball
6274 return i;
6275
6276 if(!(shield.misc1 & (shFIREBALL)))
6277 return i;
6278
6279 reflect = ((shield.misc2 & shFIREBALL) != 0);
6280 break;
6281
6282 case wRefMagic:
6283 if(itemid<0)
6284 return i;
6285
6286 if(!(shield.misc1 & shMAGIC))
6287 return i;
6288
6289 reflect = ((shield.misc2 & shMAGIC) != 0);
6290 break;
6291
6292 case wRefBeam:
6293 if(itemid<0)
6294 return i;
6295
6296 if(!(shield.misc1 & shSWORD))
6297 return i;
6298
6299 reflect = ((shield.misc2 & shSWORD) != 0);
6300 break;
6301
6302 case wRefRock:
6303 if(itemid<0)
6304 return i;
6305
6306 if(!(shield.misc1 & shROCK))
6307 return i;
6308
6309 reflect = (shield.misc2 & shROCK);
6310 break;
6311
6312 default:
6313 return -1;
6314 }
6315
6316 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || hopclk==0xFF)
6317 return i;
6318
6319 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6320
6321 paymagiccost(itemid);
6322
6323 lw->onhit(false, 1+reflect, dir);
6324 lw->ignoreHero=true;
6325 lw->ignorecombo=-1;
6326 sfx(shield.usesound,pan(x.getInt()));
6327 }
6328
6329 60230 return -1;
6330 61056 }
6331
6332 120154 void HeroClass::checkhit()
6333 {
6334
2/2
✓ Branch 0 taken 40190 times.
✓ Branch 1 taken 79964 times.
120154 if(checkhero==true)
6335 {
6336
2/2
✓ Branch 0 taken 1598 times.
✓ Branch 1 taken 78366 times.
79964 if(hclk>0)
6337 {
6338 1598 --hclk;
6339 1598 }
6340
6341
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if(NayrusLoveShieldClk>0)
6342 {
6343 --NayrusLoveShieldClk;
6344
6345 if(NayrusLoveShieldClk == 0 && nayruitem != -1)
6346 {
6347 stop_sfx(itemsbuf[nayruitem].usesound);
6348 stop_sfx(itemsbuf[nayruitem].usesound+1);
6349 nayruitem = -1;
6350 }
6351 else if(get_bit(quest_rules,qr_MORESOUNDS) && !(NayrusLoveShieldClk&0xF00) && nayruitem != -1)
6352 {
6353 stop_sfx(itemsbuf[nayruitem].usesound);
6354 cont_sfx(itemsbuf[nayruitem].usesound+1);
6355 }
6356 }
6357 79964 }
6358
6359
4/4
✓ Branch 0 taken 79658 times.
✓ Branch 1 taken 40496 times.
✓ Branch 2 taken 79643 times.
✓ Branch 3 taken 15 times.
120154 if(hclk<39 && action==gothit)
6360 {
6361 15 action=none; FFCore.setHeroAction(none);
6362 15 }
6363
6364
4/6
✓ Branch 0 taken 79658 times.
✓ Branch 1 taken 40496 times.
✓ Branch 2 taken 79658 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 79658 times.
120154 if(hclk<39 && (action==swimhit || action == sideswimhit))
6365 {
6366 SetSwim();
6367 }
6368
6369
4/4
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 119882 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 182 times.
120154 if(hclk>=40 && action==gothit)
6370 {
6371 182 int val = check_pitslide();
6372
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 182 times.
✓ Branch 3 taken 182 times.
182 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6373 {
6374
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
6375 {
6376
5/5
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 216 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 100 times.
728 switch(hitdir)
6377 {
6378 case up:
6379
6/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 202 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 200 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 202 times.
216 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6380 {
6381 14 action=none; FFCore.setHeroAction(none);
6382 14 }
6383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202 times.
202 else if (val == -1) --y;
6384
6385 216 break;
6386
6387 case down:
6388
5/6
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 86 times.
104 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6389 {
6390 18 action=none; FFCore.setHeroAction(none);
6391 18 }
6392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 else if (val == -1) ++y;
6393
6394 104 break;
6395
6396 case left:
6397
6/8
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 206 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 206 times.
212 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6398 {
6399 6 action=none; FFCore.setHeroAction(none);
6400 6 }
6401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 else if (val == -1) --x;
6402
6403 212 break;
6404
6405 case right:
6406
7/8
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 91 times.
100 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6407 {
6408 9 action=none; FFCore.setHeroAction(none);
6409 9 }
6410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
91 else if (val == -1) ++x;
6411
6412 100 break;
6413 }
6414 728 }
6415 182 }
6416 182 }
6417
6418
13/20
✓ Branch 0 taken 78399 times.
✓ Branch 1 taken 41755 times.
✓ Branch 2 taken 78399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78399 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 78312 times.
✓ Branch 7 taken 87 times.
✓ Branch 8 taken 78312 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 78312 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 78312 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 78312 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 78312 times.
✓ Branch 18 taken 43320 times.
✓ Branch 19 taken 43320 times.
120154 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6419 {
6420 85162 return;
6421 }
6422
6423
2/2
✓ Branch 0 taken 64980 times.
✓ Branch 1 taken 78311 times.
143291 for(int32_t i=0; i<Lwpns.Count(); i++)
6424 {
6425 64980 sprite *s = Lwpns.spr(i);
6426 64980 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6427 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6428 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6429
10/14
✓ Branch 0 taken 3054 times.
✓ Branch 1 taken 61926 times.
✓ Branch 2 taken 18606 times.
✓ Branch 3 taken 43320 times.
✓ Branch 4 taken 18606 times.
✓ Branch 5 taken 24714 times.
✓ Branch 6 taken 21660 times.
✓ Branch 7 taken 3054 times.
✓ Branch 8 taken 21660 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 21660 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
64980 if((!(itemid==-1&&get_bit(quest_rules,qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_bit(quest_rules,qr_FIREPROOFHERO2)))
6430 {
6431
2/10
✓ Branch 0 taken 21660 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 21660 times.
✗ Branch 9 not taken.
21660 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6432 (itemid < 0 || itemsbuf[itemid].family!=itype_dinsfire))
6433 {
6434 std::vector<int32_t> &ev = FFCore.eventData;
6435 ev.clear();
6436 ev.push_back(lwpn_dp(i)*10000);
6437 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6438 ev.push_back(0);
6439 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6440 ev.push_back(48*10000);
6441 ev.push_back(ZSD_LWPN*10000);
6442 ev.push_back(s->getUID());
6443
6444 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6445 int32_t dmg = ev[0]/10000;
6446 bool nullhit = ev[2] != 0;
6447
6448 if(nullhit) {ev.clear(); return;}
6449
6450 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6451 ev[0] = ringpower(dmg)*10000;
6452
6453 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6454 dmg = ev[0]/10000;
6455 int32_t hdir = ev[1]/10000;
6456 nullhit = ev[2] != 0;
6457 bool nayrulove = ev[3] != 0;
6458 int32_t iframes = ev[4] / 10000;
6459 ev.clear();
6460 if(nullhit) return;
6461 if(!nayrulove)
6462 {
6463 game->set_life(zc_max(game->get_life()-dmg,0));
6464 }
6465
6466 hitdir = hdir;
6467
6468 if (action != rafting && action != freeze && action != sideswimfreeze)
6469 {
6470 if (IsSideSwim())
6471 {
6472 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6473 }
6474 else if (action == swimming || hopclk == 0xFF)
6475 {
6476 action=swimhit; FFCore.setHeroAction(swimhit);
6477 }
6478 else
6479 {
6480 action=gothit; FFCore.setHeroAction(gothit);
6481 }
6482 }
6483
6484 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6485 {
6486 spins = charging = attackclk = 0;
6487 attack=none;
6488 tapping = false;
6489 }
6490
6491 hclk=iframes;
6492 sfx(getHurtSFX(),pan(x.getInt()));
6493 return;
6494 }
6495 21660 }
6496
6497 // check enemy weapons true, 1, -1
6498 //
6499
2/2
✓ Branch 0 taken 21418 times.
✓ Branch 1 taken 242 times.
27768 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6500 {
6501
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 242 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
242 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6502 {
6503
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6504 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6505 242 itemid = vbound(itemid, 0, MAXITEMS-1);
6506
6507
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 for(int32_t j=0; j<Ewpns.Count(); j++)
6508 {
6509 sprite *t = Ewpns.spr(j);
6510
6511 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6512 {
6513 bool reflect = false;
6514 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6515 switch(t->id)
6516 {
6517 case ewBrang:
6518 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6519
6520 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6521 goto killweapon;
6522
6523 case ewArrow:
6524 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6525
6526 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6527 goto killweapon;
6528
6529 case ewRock:
6530 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6531
6532 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6533 goto killweapon;
6534
6535 case ewFireball2:
6536 case ewFireball:
6537 {
6538 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6539
6540 if(!(itemsbuf[itemid].misc3 & mask)) break;
6541
6542 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6543 goto killweapon;
6544 }
6545
6546 case ewSword:
6547 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6548
6549 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6550 goto killweapon;
6551
6552 case wRefMagic:
6553 case ewMagic:
6554 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6555
6556 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6557 goto killweapon;
6558
6559 case wScript1:
6560 case wScript2:
6561 case wScript3:
6562 case wScript4:
6563 case wScript5:
6564 case wScript6:
6565 case wScript7:
6566 case wScript8:
6567 case wScript9:
6568 case wScript10:
6569 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6570
6571 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6572 goto killweapon;
6573
6574 case ewLitBomb:
6575 case ewLitSBomb:
6576 killweapon:
6577 ((weapon*)s)->dead=1;
6578 weapon *ew = ((weapon*)t);
6579 int32_t oldid = ew->id;
6580 ew->onhit(true, reflect ? 2 : 1, s->dir);
6581
6582 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6583 {
6584 Lwpns.add(ew);
6585 Ewpns.remove(ew);
6586 ew->isLWeapon = true; //Make sure this gets set everywhere!
6587 }
6588
6589 if(ew->id==wRefMagic)
6590 {
6591 ew->ignoreHero=true;
6592 ew->ignorecombo=-1;
6593 }
6594
6595 break;
6596 }
6597
6598 break;
6599 }
6600 }
6601 242 }
6602 242 }
6603
6604
5/6
✓ Branch 0 taken 7179 times.
✓ Branch 1 taken 14481 times.
✓ Branch 2 taken 3054 times.
✓ Branch 3 taken 4125 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3054 times.
21660 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_bit(quest_rules,qr_OUCHBOMBS)))
6605 {
6606
7/10
✓ Branch 0 taken 14377 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 14480 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
14481 if(((s->id==wBomb)||(s->id==wSBomb)) && s->hit(this) && !superman && (scriptcoldet&1) && !fallclk)
6607 {
6608 1 std::vector<int32_t> &ev = FFCore.eventData;
6609 1 ev.clear();
6610
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6611 1 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6612 1 ev.push_back(0);
6613 1 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6614 1 ev.push_back(48*10000);
6615 1 ev.push_back(ZSD_LWPN*10000);
6616 1 ev.push_back(s->getUID());
6617
6618 1 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6619 1 int32_t dmg = ev[0]/10000;
6620 1 bool nullhit = ev[2] != 0;
6621
6622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(nullhit) {ev.clear(); return;}
6623
6624 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6625 1 ev[0] = ringpower(dmg)*10000;
6626
6627 1 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6628 1 dmg = ev[0]/10000;
6629 1 int32_t hdir = ev[1]/10000;
6630 1 nullhit = ev[2] != 0;
6631 1 bool nayrulove = ev[3] != 0;
6632 1 int32_t iframes = ev[4] / 10000;
6633 1 ev.clear();
6634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(nullhit) return;
6635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!nayrulove)
6636 {
6637
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6638 1 }
6639
6640 1 hitdir = hdir;
6641
6642
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if (action != rafting && action != freeze && action != sideswimfreeze)
6643 {
6644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (IsSideSwim())
6645 {
6646 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6647 }
6648
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 else if (action == swimming || hopclk == 0xFF)
6649 {
6650 action=swimhit; FFCore.setHeroAction(swimhit);
6651 }
6652 else
6653 {
6654 1 action=gothit; FFCore.setHeroAction(gothit);
6655 }
6656 1 }
6657
6658
4/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6659 {
6660 spins = charging = attackclk = 0;
6661 attack=none;
6662 tapping = false;
6663 }
6664
6665 1 hclk=iframes;
6666 1 sfx(getHurtSFX(),pan(x.getInt()));
6667 1 return;
6668 }
6669 14480 }
6670
6671
3/8
✓ Branch 0 taken 21659 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21659 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 21659 times.
✗ Branch 7 not taken.
21659 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6672 {
6673 std::vector<int32_t> &ev = FFCore.eventData;
6674 ev.clear();
6675 ev.push_back(0);
6676 ev.push_back(s->dir*10000);
6677 ev.push_back(0);
6678 ev.push_back(0);
6679 ev.push_back(ZSD_LWPN*10000);
6680 ev.push_back(s->getUID());
6681
6682 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6683 bool nullhit = ev[2] != 0;
6684 if(nullhit) {ev.clear(); return;}
6685
6686 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6687 int32_t hdir = ev[1]/10000;
6688 nullhit = ev[2] != 0;
6689 ev.clear();
6690 if(nullhit) return;
6691
6692 reset_hookshot();
6693 xofs=1000;
6694 action=inwind; FFCore.setHeroAction(inwind);
6695 dir=s->dir=hdir;
6696 spins = charging = attackclk = 0;
6697
6698 // In case Hero used two whistles in a row, summoning two whirlwinds,
6699 // check which whistle's whirlwind picked him up so the correct
6700 // warp ring will be used
6701 int32_t whistle=((weapon*)s)->parentitem;
6702
6703 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6704 whistleitem=whistle;
6705
6706 return;
6707 }
6708 21659 }
6709
6710
5/8
✓ Branch 0 taken 78311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75980 times.
✓ Branch 3 taken 2331 times.
✓ Branch 4 taken 75980 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 75980 times.
154291 if(action==rafting || action==freeze || action==sideswimfreeze ||
6711
4/8
✓ Branch 0 taken 75980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75980 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 75980 times.
✗ Branch 7 not taken.
75980 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6712 2331 return;
6713
6714 75980 int32_t hit2 = -1;
6715 75980 do
6716 {
6717
2/2
✓ Branch 0 taken 14356 times.
✓ Branch 1 taken 61696 times.
76052 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6718 61696 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6719
6720
2/2
✓ Branch 0 taken 75009 times.
✓ Branch 1 taken 1043 times.
76052 if(hit2!=-1)
6721 {
6722
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 971 times.
1043 if (hithero(hit2) == 0) return;
6723 72 }
6724
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 75009 times.
75081 } while (hit2 != -1);
6725
5/6
✓ Branch 0 taken 72106 times.
✓ Branch 1 taken 2903 times.
✓ Branch 2 taken 61056 times.
✓ Branch 3 taken 11050 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61056 times.
75009 if (superman || !(scriptcoldet&1) || fallclk) return;
6726 61056 hit2 = LwpnHit();
6727
6728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61056 times.
61056 if(hit2!=-1)
6729 {
6730 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6731 std::vector<int32_t> &ev = FFCore.eventData;
6732 ev.clear();
6733 ev.push_back((lwpn_dp(hit2)*10000));
6734 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6735 ev.push_back(0);
6736 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6737 ev.push_back(48*10000);
6738 ev.push_back(ZSD_LWPN*10000);
6739 ev.push_back(lwpnspr->getUID());
6740
6741 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6742 int32_t dmg = ev[0]/10000;
6743 bool nullhit = ev[2] != 0;
6744
6745 if(nullhit) {ev.clear(); return;}
6746
6747 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6748 ev[0] = ringpower(dmg)*10000;
6749
6750 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6751 dmg = ev[0]/10000;
6752 int32_t hdir = ev[1]/10000;
6753 nullhit = ev[2] != 0;
6754 bool nayrulove = ev[3] != 0;
6755 int32_t iframes = ev[4] / 10000;
6756 ev.clear();
6757 if(nullhit) return;
6758 if(!nayrulove)
6759 {
6760 game->set_life(zc_max(game->get_life()-dmg,0));
6761 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6762 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6763 }
6764
6765 hitdir = hdir;
6766 lwpnspr->onhit(false);
6767
6768 if (IsSideSwim())
6769 {
6770 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6771 }
6772 else if(action==swimming || hopclk==0xFF)
6773 {
6774 action=swimhit; FFCore.setHeroAction(swimhit);
6775 }
6776 else
6777 {
6778 action=gothit; FFCore.setHeroAction(gothit);
6779 }
6780
6781 hclk=iframes;
6782
6783 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6784 {
6785 spins = charging = attackclk = 0;
6786 attack=none;
6787 tapping = false;
6788 }
6789
6790 sfx(getHurtSFX(),pan(x.getInt()));
6791 return;
6792 }
6793
6794 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6795
6796 61056 hit2 = EwpnHit();
6797
6798
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 61049 times.
61056 if(hit2!=-1)
6799 {
6800 7 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6801 7 std::vector<int32_t> &ev = FFCore.eventData;
6802 7 ev.clear();
6803 7 ev.push_back((ewpn_dp(hit2)*10000));
6804 7 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6805 7 ev.push_back(0);
6806 7 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6807 7 ev.push_back(48*10000);
6808 7 ev.push_back(ZSD_EWPN*10000);
6809 7 ev.push_back(ewpnspr->getUID());
6810
6811 7 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6812 7 int32_t dmg = ev[0]/10000;
6813 7 bool nullhit = ev[2] != 0;
6814
6815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(nullhit) {ev.clear(); return;}
6816
6817 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6818 7 ev[0] = ringpower(dmg)*10000;
6819
6820 7 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6821 7 dmg = ev[0]/10000;
6822 7 int32_t hdir = ev[1]/10000;
6823 7 nullhit = ev[2] != 0;
6824 7 bool nayrulove = ev[3] != 0;
6825 7 int32_t iframes = ev[4] / 10000;
6826 7 ev.clear();
6827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(nullhit) return;
6828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!nayrulove)
6829 {
6830
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 game->set_life(zc_max(game->get_life()-dmg,0));
6831 7 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6832 7 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6833 7 }
6834
6835 7 hitdir = hdir;
6836 7 ewpnspr->onhit(false);
6837
6838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (IsSideSwim())
6839 {
6840 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6841 }
6842
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 else if(action==swimming || hopclk==0xFF)
6843 {
6844 action=swimhit; FFCore.setHeroAction(swimhit);
6845 }
6846 else
6847 {
6848 7 action=gothit; FFCore.setHeroAction(gothit);
6849 }
6850
6851 7 hclk=iframes;
6852
6853
5/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
7 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6854 {
6855 4 spins = charging = attackclk = 0;
6856 4 attack=none;
6857 4 tapping = false;
6858 4 }
6859
6860 7 sfx(getHurtSFX(),pan(x.getInt()));
6861 7 return;
6862 }
6863 //else { sethitHeroUID(HIT_BY_EWEAPON,(0)); } //fails to clear
6864
6865 // The rest of this method deals with damage combos, which can be jumped over.
6866
2/4
✓ Branch 0 taken 61049 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61049 times.
✗ Branch 3 not taken.
61049 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6867
6868 61049 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6869 61049 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61049 times.
61049 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61049 times.
61049 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6872
6873
2/2
✓ Branch 0 taken 61049 times.
✓ Branch 1 taken 128789 times.
189838 for(int32_t i=get_bit(quest_rules, qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6874 128789 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6875 79964 }
6876
6877 58 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6878 {
6879 58 return checkdamagecombos(dx,dx,dy,dy);
6880 }
6881
6882 4 void HeroClass::doHit(int32_t hdir)
6883 {
6884 4 hitdir = hdir;
6885
6886
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 if (action != rafting && action != freeze && action != sideswimfreeze)
6887 {
6888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (IsSideSwim())
6889 {
6890 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6891 }
6892
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 else if (action == swimming || hopclk == 0xFF)
6893 {
6894 action=swimhit; FFCore.setHeroAction(swimhit);
6895 }
6896 else
6897 {
6898 4 action=gothit; FFCore.setHeroAction(gothit);
6899 }
6900 4 }
6901
6902 4 hclk=48;
6903
6904
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
4 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6905 {
6906 spins = charging = attackclk = 0;
6907 attack=none;
6908 tapping = false;
6909 }
6910
6911 4 sfx(getHurtSFX(),pan(x.getInt()));
6912 4 }
6913
6914 183811 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6915 {
6916
3/6
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183811 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 183811 times.
183811 if(hclk || superman || fallclk)
6917 return false;
6918
6919 183811 int32_t hp_mod[4] = {0};
6920 int32_t cid[8];
6921 183811 byte hasKB = 0;
6922
6923 {
6924
2/2
✓ Branch 0 taken 104385 times.
✓ Branch 1 taken 79426 times.
183811 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6925 183811 newcombo& cmb = combobuf[cid[0]];
6926
2/4
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183811 times.
✗ Branch 3 not taken.
183811 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6927 {
6928 if(cmb.usrflags&cflag1)
6929 hp_mod[0] = cmb.attributes[0] / -10000L;
6930 else
6931 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6932 if(!(cmb.usrflags&cflag2))
6933 hasKB |= 1<<0;
6934 }
6935 }
6936 {
6937
2/2
✓ Branch 0 taken 104385 times.
✓ Branch 1 taken 79426 times.
183811 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6938 183811 newcombo& cmb = combobuf[cid[1]];
6939
2/4
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183811 times.
✗ Branch 3 not taken.
183811 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6940 {
6941 if(cmb.usrflags&cflag1)
6942 hp_mod[1] = cmb.attributes[0] / -10000L;
6943 else
6944 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6945 if(!(cmb.usrflags&cflag2))
6946 hasKB |= 1<<1;
6947 }
6948 }
6949 {
6950
2/2
✓ Branch 0 taken 104385 times.
✓ Branch 1 taken 79426 times.
183811 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6951 183811 newcombo& cmb = combobuf[cid[2]];
6952
2/4
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183811 times.
✗ Branch 3 not taken.
183811 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6953 {
6954 if(cmb.usrflags&cflag1)
6955 hp_mod[2] = cmb.attributes[0] / -10000L;
6956 else
6957 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6958 if(!(cmb.usrflags&cflag2))
6959 hasKB |= 1<<2;
6960 }
6961 }
6962 {
6963
2/2
✓ Branch 0 taken 104385 times.
✓ Branch 1 taken 79426 times.
183811 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
6964 183811 newcombo& cmb = combobuf[cid[3]];
6965
2/4
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183811 times.
✗ Branch 3 not taken.
183811 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6966 {
6967 if(cmb.usrflags&cflag1)
6968 hp_mod[3] = cmb.attributes[0] / -10000L;
6969 else
6970 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6971 if(!(cmb.usrflags&cflag2))
6972 hasKB |= 1<<3;
6973 }
6974 }
6975
6976 183811 int32_t bestcid=0;
6977 183811 int32_t hp_modtotal=0;
6978
2/2
✓ Branch 0 taken 99893 times.
✓ Branch 1 taken 83918 times.
183811 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6979
2/2
✓ Branch 0 taken 99852 times.
✓ Branch 1 taken 83959 times.
183811 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6980
2/2
✓ Branch 0 taken 99893 times.
✓ Branch 1 taken 83918 times.
183811 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6981
2/2
✓ Branch 0 taken 99852 times.
✓ Branch 1 taken 83959 times.
183811 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6982
6983
2/2
✓ Branch 0 taken 367622 times.
✓ Branch 1 taken 183811 times.
551433 for (int32_t i = 0; i <= 1; ++i)
6984 {
6985
2/2
✓ Branch 0 taken 301736 times.
✓ Branch 1 taken 65886 times.
367622 if(tmpscr2[i].valid!=0)
6986 {
6987
2/2
✓ Branch 0 taken 34824 times.
✓ Branch 1 taken 31062 times.
65886 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
6988 {
6989
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34824 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34824 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34824 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34824 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6993 34824 }
6994 else
6995 {
6996
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31062 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6997
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31062 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31062 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6999
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31062 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7000 }
7001 65886 }
7002 367622 }
7003
7004
2/2
✓ Branch 0 taken 735244 times.
✓ Branch 1 taken 183811 times.
919055 for(int32_t i=0; i<4; i++)
7005 {
7006
2/2
✓ Branch 0 taken 378180 times.
✓ Branch 1 taken 357064 times.
735244 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7007 {
7008
1/2
✓ Branch 0 taken 378180 times.
✗ Branch 1 not taken.
378180 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
7009 {
7010
1/2
✓ Branch 0 taken 378180 times.
✗ Branch 1 not taken.
378180 if(hp_mod[i] < hp_modtotal)
7011 {
7012 hp_modtotal = hp_mod[i];
7013 bestcid = cid[i];
7014 }
7015 378180 }
7016 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
7017 {
7018 if(hp_mod[i] > hp_modtotal)
7019 {
7020 hp_modtotal = hp_mod[i];
7021 bestcid = cid[i];
7022 }
7023 }
7024 378180 }
7025
1/2
✓ Branch 0 taken 357064 times.
✗ Branch 1 not taken.
357064 else if(hp_mod[i] < hp_modtotal)
7026 {
7027 hp_modtotal = hp_mod[i];
7028 bestcid = cid[i];
7029 }
7030 735244 }
7031
7032 {
7033 183811 cid[4] = MAPFFCOMBO(dx1,dy1);
7034 183811 newcombo& cmb = combobuf[cid[4]];
7035
3/4
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183461 times.
✓ Branch 3 taken 350 times.
183811 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7036 {
7037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if(cmb.usrflags&cflag1 )
7038 hp_mod[0] = cmb.attributes[0]/10000L;
7039 else
7040 350 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7041
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(!(cmb.usrflags&cflag2))
7042 hasKB |= 1<<4;
7043 350 }
7044 }
7045 {
7046 183811 cid[5] = MAPFFCOMBO(dx1,dy2);
7047 183811 newcombo& cmb = combobuf[cid[5]];
7048
3/4
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183470 times.
✓ Branch 3 taken 341 times.
183811 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7049 {
7050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
341 if(cmb.usrflags&cflag1 )
7051 hp_mod[1] = cmb.attributes[0]/10000L;
7052 else
7053 341 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7054
1/2
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
341 if(!(cmb.usrflags&cflag2))
7055 hasKB |= 1<<5;
7056 341 }
7057 }
7058 {
7059 183811 cid[6] = MAPFFCOMBO(dx2,dy1);
7060 183811 newcombo& cmb = combobuf[cid[6]];
7061
3/4
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183449 times.
✓ Branch 3 taken 362 times.
183811 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7062 {
7063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 if(cmb.usrflags&cflag1 )
7064 hp_mod[2] = cmb.attributes[0]/10000L;
7065 else
7066 362 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7067
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if(!(cmb.usrflags&cflag2))
7068 hasKB |= 1<<6;
7069 362 }
7070 }
7071 {
7072 183811 cid[7] = MAPFFCOMBO(dx2,dy2);
7073 183811 newcombo& cmb = combobuf[cid[7]];
7074
3/4
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183470 times.
✓ Branch 3 taken 341 times.
183811 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7075 {
7076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
341 if(cmb.usrflags&cflag1 )
7077 hp_mod[3] = cmb.attributes[0]/10000L;
7078 else
7079 341 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7080
1/2
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
341 if(!(cmb.usrflags&cflag2))
7081 hasKB |= 1<<7;
7082 341 }
7083 }
7084
7085 183811 int32_t bestffccid = 0;
7086 183811 int32_t hp_modtotalffc = 0;
7087
7088
2/2
✓ Branch 0 taken 367622 times.
✓ Branch 1 taken 183811 times.
551433 for (int32_t i = 0; i <= 1; ++i)
7089 {
7090
2/2
✓ Branch 0 taken 301736 times.
✓ Branch 1 taken 65886 times.
367622 if(tmpscr2[i].valid!=0)
7091 {
7092
2/2
✓ Branch 0 taken 34824 times.
✓ Branch 1 taken 31062 times.
65886 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
7093 {
7094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34824 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34824 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7096
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34824 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34824 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7098 34824 }
7099 else
7100 {
7101
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31062 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7102
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31062 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31062 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31062 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7105 }
7106 65886 }
7107 367622 }
7108
7109
2/2
✓ Branch 0 taken 735244 times.
✓ Branch 1 taken 183811 times.
919055 for(int32_t i=0; i<4; i++)
7110 {
7111
2/2
✓ Branch 0 taken 378180 times.
✓ Branch 1 taken 357064 times.
735244 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7112 {
7113
1/2
✓ Branch 0 taken 378180 times.
✗ Branch 1 not taken.
378180 if(hp_modtotalffc >= 0)
7114 {
7115
1/2
✓ Branch 0 taken 378180 times.
✗ Branch 1 not taken.
378180 if(hp_mod[i] < hp_modtotalffc)
7116 {
7117 hp_modtotalffc = hp_mod[i];
7118 bestffccid = cid[4+i];
7119 }
7120 378180 }
7121 else if(hp_mod[i] < 0)
7122 {
7123 if(hp_mod[i] > hp_modtotalffc)
7124 {
7125 hp_modtotalffc = hp_mod[i];
7126 bestffccid = cid[4+i];
7127 }
7128 }
7129 378180 }
7130
2/2
✓ Branch 0 taken 356681 times.
✓ Branch 1 taken 383 times.
357064 else if(hp_mod[i] < hp_modtotalffc)
7131 {
7132 383 hp_modtotalffc = hp_mod[i];
7133 383 bestffccid = cid[4+i];
7134 383 }
7135 735244 }
7136
7137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183811 times.
183811 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7138
1/2
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
183811 if(hp_modtotalffc < hp_modmin) bestcid = bestffccid;
7139
7140 183811 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7141 183811 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7142 183811 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7143
1/2
✓ Branch 0 taken 183811 times.
✗ Branch 1 not taken.
183811 if(current_ring)
7144 {
7145 global_defring = !global_defring;
7146 global_perilring = !global_perilring;
7147 }
7148 183811 int32_t itemid = current_item_id(itype_boots);
7149
7150
2/2
✓ Branch 0 taken 135295 times.
✓ Branch 1 taken 48516 times.
183811 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7151
2/2
✓ Branch 0 taken 135295 times.
✓ Branch 1 taken 48516 times.
183811 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7152
7153
2/2
✓ Branch 0 taken 183428 times.
✓ Branch 1 taken 383 times.
183811 if(hp_modmin<0)
7154 {
7155
8/14
✓ Branch 0 taken 374 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 374 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 374 times.
✓ Branch 10 taken 374 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 374 times.
383 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7156 {
7157
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if (!do_health_check) return true;
7158 3 std::vector<int32_t> &ev = FFCore.eventData;
7159 3 ev.clear();
7160 3 ev.push_back(-hp_modmin*10000);
7161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 ev.push_back((hasKB ? dir^1 : -1)*10000);
7162 3 ev.push_back(0);
7163 3 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7164 3 ev.push_back(48*10000);
7165 3 ev.push_back(ZSD_COMBODATA*10000);
7166 3 ev.push_back(bestcid);
7167
7168 3 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7169 3 int32_t dmg = ev[0]/10000;
7170 3 bool nullhit = ev[2] != 0;
7171
7172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(nullhit) {ev.clear(); return false;}
7173
7174 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7175 3 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7176
7177 3 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7178 3 dmg = ev[0]/10000;
7179 3 int32_t hdir = ev[1]/10000;
7180 3 nullhit = ev[2] != 0;
7181 3 bool nayrulove = ev[3] != 0;
7182 3 int32_t iframes = ev[4] / 10000;
7183 3 ev.clear();
7184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(nullhit) return false;
7185
7186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!nayrulove)
7187 {
7188
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 game->set_life(zc_max(game->get_life()-dmg,0));
7189 3 }
7190
7191 3 hitdir = hdir;
7192 3 doHit(hitdir);
7193 3 hclk = iframes;
7194 3 return true;
7195 }
7196
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 50 times.
374 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7197 374 }
7198
7199 183802 return false;
7200 183811 }
7201
7202 1045 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7203 {
7204
1/2
✓ Branch 0 taken 1045 times.
✗ Branch 1 not taken.
1045 if(force_hdir > 3) force_hdir = -1;
7205 1045 enemy* enemyptr = (enemy*)guys.spr(hit2);
7206
1/2
✓ Branch 0 taken 1045 times.
✗ Branch 1 not taken.
1045 if(!enemyptr) return 0;
7207 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7208 1045 int32_t stompid = current_item_id(itype_stompboots);
7209
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1045 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7210 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7211 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7212 {
7213 paymagiccost(stompid);
7214 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7215
7216 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7217 {
7218 fall = -(itemsbuf[stompid].misc1);
7219 }
7220
7221 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7222 game->set_item(stompid,false);
7223
7224 // Stomp Boots script
7225 if(itemsbuf[stompid].script != 0 && !(item_doscript[stompid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
7226 {
7227 //clear the item script stack for a new script
7228 ri = &(itemScriptData[stompid]);
7229 for ( int32_t q = 0; q < 1024; q++ ) item_stack[stompid][q] = 0xFFFF;
7230 ri->Clear();
7231 //itemScriptData[(stompid & 0xFFF)].Clear();
7232 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(stompid & 0xFFF)][q] = 0;
7233 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid & 0xFFF);
7234 item_doscript[stompid] = 1;
7235 itemscriptInitialised[stompid] = 0;
7236 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid);
7237 }
7238
7239 return -1;
7240 }
7241
4/6
✓ Branch 0 taken 1045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 951 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
1045 else if(superman || !(scriptcoldet&1) || fallclk)
7242 951 return 0;
7243 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7244 //!Add a flag check to this if:
7245
5/6
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 12 times.
94 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7246
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7247 {
7248 74 return -1;
7249 }
7250
7251 20 std::vector<int32_t> &ev = FFCore.eventData;
7252 20 ev.clear();
7253 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7254 20 ev.push_back((enemy_dp(hit2) *10000));
7255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7256 20 ev.push_back(0);
7257 20 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7258 20 ev.push_back(48*10000);
7259 20 ev.push_back(ZSD_NPC*10000);
7260 20 ev.push_back(enemyptr->getUID());
7261
7262 20 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7263 20 int32_t dmg = ev[0] / 10000;
7264 20 bool nullhit = ev[2] != 0;
7265
7266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(nullhit) {ev.clear(); return -1;}
7267
7268 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7269 20 ev[0] = ((ringpower(dmg)*10000));
7270
7271 20 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7272 20 dmg = ev[0] / 10000;
7273 20 int32_t hdir = ev[1] / 10000;
7274 20 nullhit = ev[2] != 0;
7275 20 bool nayrulove = ev[3] != 0;
7276 20 int32_t iframes = ev[4] / 10000;
7277 20 ev.clear();
7278
7279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(nullhit) return -1;
7280
7281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(!nayrulove)
7282 {
7283
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 game->set_life(zc_max(game->get_life()-dmg,0));
7284 20 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7285 20 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7286 20 }
7287
7288 20 hitdir = hdir;
7289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (IsSideSwim())
7290 {
7291 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7292 }
7293
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 else if(action==swimming || hopclk==0xFF)
7294 {
7295 action=swimhit; FFCore.setHeroAction(swimhit);
7296 }
7297 else
7298 {
7299 20 action=gothit; FFCore.setHeroAction(gothit);
7300 }
7301
7302 20 hclk=iframes;
7303 20 sfx(getHurtSFX(),pan(x.getInt()));
7304
7305
5/8
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
20 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7306 {
7307 8 spins = charging = attackclk = 0;
7308 8 attack=none;
7309 8 tapping = false;
7310 8 }
7311
7312 20 enemy_scored(hit2);
7313 20 int32_t dm7 = enemyptr->dmisc7;
7314 20 int32_t dm8 = enemyptr->dmisc8;
7315
7316
2/3
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
20 switch(enemyptr->family)
7317 {
7318 case eeWALLM:
7319 if(enemyptr->hp>0)
7320 {
7321 GrabHero(hit2);
7322 inwallm=true;
7323 action=none; FFCore.setHeroAction(none);
7324 }
7325 break;
7326
7327 //case eBUBBLEST:
7328 //case eeBUBBLE:
7329 case eeWALK:
7330 {
7331 14 int32_t itemid = current_item_id(itype_whispring);
7332 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7333
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7334
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7335
7336
3/7
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
14 switch(dm7)
7337 {
7338 case e7tTEMPJINX:
7339
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if(dm8==0 || dm8==2)
7340
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
4 if(swordclk>=0 && !(sworddivisor==0))
7341 2 swordclk=150;
7342
7343
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(dm8==1 || dm8==2)
7344 if(itemclk>=0 && !(itemdivisor==0))
7345 itemclk=150;
7346
7347 2 break;
7348
7349 case e7tPERMJINX:
7350 if(dm8==0 || dm8==2)
7351 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7352
7353 if(dm8==1 || dm8==2)
7354 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7355
7356 break;
7357
7358 case e7tUNJINX:
7359
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(dm8==0 || dm8==2)
7360 swordclk=0;
7361
7362
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if(dm8==1 || dm8==2)
7363 1 itemclk=0;
7364
7365 1 break;
7366
7367 case e7tTAKEMAGIC:
7368 game->change_dmagic(-dm8*game->get_magicdrainrate());
7369 break;
7370
7371 case e7tTAKERUPEES:
7372 game->change_drupy(-dm8);
7373 break;
7374
7375 case e7tDRUNK:
7376 drunkclk += dm8;
7377 break;
7378 }
7379 14 verifyAWpn();
7380
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(dm7 >= e7tEATITEMS)
7381 {
7382 EatHero(hit2);
7383 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7384 action=none; FFCore.setHeroAction(none);
7385 }
7386 }
7387 14 }
7388 20 return 0;
7389 1045 }
7390
7391 4217 void HeroClass::addsparkle(int32_t wpn)
7392 {
7393 //return;
7394 4217 weapon *w = (weapon*)Lwpns.spr(wpn);
7395 4217 int32_t itemid = w->parentitem;
7396
7397
1/2
✓ Branch 0 taken 4217 times.
✗ Branch 1 not taken.
4217 if(itemid<0)
7398 return;
7399
7400 4217 int32_t itemtype = itemsbuf[itemid].family;
7401
7402
3/4
✓ Branch 0 taken 4217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1058 times.
✓ Branch 3 taken 3159 times.
4217 if(itemtype!=itype_cbyrna && frame%4)
7403 3159 return;
7404
7405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1058 times.
1058 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1058 times.
1058 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7407 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7408
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1058 times.
✓ Branch 2 taken 1058 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1058 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7409 1058 int32_t direction=w->dir;
7410
7411
1/2
✓ Branch 0 taken 1058 times.
✗ Branch 1 not taken.
1058 if(sparkle_type)
7412 {
7413 int32_t h=0;
7414 int32_t v=0;
7415
7416 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7417 {
7418 h=-1;
7419 }
7420
7421 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7422 {
7423 h=1;
7424 }
7425
7426 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7427 {
7428 v=-1;
7429 }
7430
7431 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7432 {
7433 v=1;
7434 }
7435
7436 // Damaging boomerang sparkle?
7437 if(wpn3 && itemtype==itype_brang)
7438 {
7439 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7440 // whatever it just bounced off of if it's shielded from that direction.
7441 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7442 direction=oppositeDir[direction];
7443 }
7444 if(itemtype==itype_brang && get_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7445 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7446 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7447 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7448 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7449 }
7450 4217 }
7451
7452 // For wPhantoms
7453 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7454 {
7455 if(frame%4) return;
7456
7457 int32_t arrow = -1;
7458
7459 for(int32_t i=0; i<Lwpns.Count(); i++)
7460 {
7461 weapon *w = (weapon*)Lwpns.spr(i);
7462
7463 if(w->id == wPhantom && w->type == type1)
7464 {
7465 arrow = i;
7466 break;
7467 }
7468 }
7469
7470 if(arrow==-1)
7471 {
7472 return;
7473 }
7474
7475 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7476 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7477 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7478 }
7479
7480 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7481 79959 void HeroClass::PhantomsCleanup()
7482 {
7483
1/2
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
79959 if(Lwpns.idCount(wPhantom))
7484 {
7485 for(int32_t i=0; i<Lwpns.Count(); i++)
7486 {
7487 weapon *w = ((weapon *)Lwpns.spr(i));
7488 if ( w->id == wPhantom && !w->isScriptGenerated() )
7489 {
7490 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7491 {
7492 Lwpns.remove(w);
7493 }
7494 }
7495 }
7496 }
7497 79959 }
7498
7499 //Waitframe handler for refilling operations
7500 static void do_refill_waitframe()
7501 {
7502 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7503 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7504 {
7505 script_drawing_commands.Clear();
7506 if(DMaps[currdmap].passive_sub_script != 0)
7507 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7508 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
7509 {
7510 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7511 passive_subscreen_waitdraw = false;
7512 }
7513 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7514 }
7515 advanceframe(true);
7516 }
7517 //Special handler if it's a "fairy revive"
7518 static void do_death_refill_waitframe()
7519 {
7520 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7521 //This script should be able to draw a 'fairy saving the player' animation -Em
7522 do_refill_waitframe();
7523 }
7524
7525 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7526 {
7527 int32_t found_unowned = -1;
7528 for(int q = 0; q < MAXITEMS; ++q)
7529 {
7530 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7531 {
7532 if(game->get_item(q))
7533 return q;
7534 if(unowned)
7535 found_unowned = q;
7536 }
7537 }
7538 return found_unowned;
7539 }
7540
7541 int32_t getPushDir(int32_t flag)
7542 {
7543 switch(flag)
7544 {
7545 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7546 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7547 case mfPUSHUINS:
7548 return up;
7549 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7550 return down;
7551 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7552 case mfPUSHLRINS: case mfPUSHLINS:
7553 return left;
7554 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7555 return right;
7556 }
7557 return -1;
7558 }
7559
7560 // returns true when game over
7561 226002 bool HeroClass::animate(int32_t)
7562 {
7563 226002 int32_t lsave=0;
7564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226002 times.
226002 if(immortal > 0)
7565 --immortal;
7566 226002 prompt_combo = 0;
7567
2/2
✓ Branch 0 taken 146038 times.
✓ Branch 1 taken 79964 times.
226002 if (onpassivedmg)
7568 {
7569 146038 onpassivedmg=false;
7570 146038 }
7571
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 else if (damageovertimeclk)
7572 {
7573 damageovertimeclk = 0;
7574 }
7575
7576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226002 times.
226002 if(cheats_execute_goto)
7577 {
7578 didpit=true;
7579 pitx=x;
7580 pity=y;
7581 dowarp(3,0);
7582 cheats_execute_goto=false;
7583 solid_update(false);
7584 return false;
7585 }
7586
7587
1/2
✓ Branch 0 taken 226002 times.
✗ Branch 1 not taken.
226002 if(cheats_execute_light)
7588 {
7589 naturaldark = !naturaldark;
7590 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7591 cheats_execute_light = false;
7592 }
7593
7594
3/4
✓ Branch 0 taken 79964 times.
✓ Branch 1 taken 146038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 79964 times.
226002 if(action!=climbcovertop&&action!=climbcoverbottom)
7595 {
7596 79964 climb_cover_x=-1000;
7597 79964 climb_cover_y=-1000;
7598 79964 }
7599
7600
1/2
✓ Branch 0 taken 226002 times.
✗ Branch 1 not taken.
226002 if(mirror_portal)
7601 {
7602 mirror_portal->animate(0);
7603 if(abs(x - mirror_portal->x) < 12
7604 && abs(y - mirror_portal->y) < 12)
7605 {
7606 if(can_mirror_portal)
7607 {
7608 //Store some values to restore if 'warp fails'
7609 int32_t tLastEntrance = lastentrance,
7610 tLastEntranceDMap = lastentrance_dmap,
7611 tContScr = game->get_continue_scrn(),
7612 tContDMap = game->get_continue_dmap();
7613 int32_t sourcescr = currscr, sourcedmap = currdmap;
7614 zfix tx = x, ty = y, tz = z;
7615 x = mirror_portal->x;
7616 y = mirror_portal->y;
7617
7618 int32_t weff = mirror_portal->weffect,
7619 wsfx = mirror_portal->wsfx;
7620
7621 FFCore.warp_player(wtIWARP, mirror_portal->destdmap, mirror_portal->destscr,
7622 -1, -1, weff, wsfx, 0, -1);
7623
7624 if(mirrorBonk()) //Invalid landing, warp back!
7625 {
7626 action = none; FFCore.setHeroAction(none);
7627 lastentrance = tLastEntrance;
7628 lastentrance_dmap = tLastEntranceDMap;
7629 game->set_continue_scrn(tContScr);
7630 game->set_continue_dmap(tContDMap);
7631 x = tx;
7632 y = ty;
7633 z = tz;
7634 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7635 wsfx, 0, -1);
7636 can_mirror_portal = false;
7637 }
7638 else game->clear_portal(); //Remove portal once used
7639 }
7640 }
7641 else can_mirror_portal = true;
7642 }
7643
7644
3/4
✓ Branch 0 taken 79964 times.
✓ Branch 1 taken 146038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 79964 times.
226002 if(z<=8&&fakez<=8)
7645 {
7646
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 79345 times.
79964 if (get_bit(quest_rules, qr_GRASS_SENSITIVE))
7647 {
7648 619 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7650 {
7651
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7652
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7653
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7654
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7655 619 }
7656
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
619 if(g1 && g2 && g3 && g4)
7657 {
7658 if(decorations.idCount(dTALLGRASS)==0)
7659 {
7660 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7661 }
7662 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+12)].attribytes[3];
7663 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7664 sfx(thesfx,pan((int32_t)x));
7665 }
7666 619 }
7667 else
7668 {
7669 79345 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7670
2/2
✓ Branch 0 taken 12934 times.
✓ Branch 1 taken 66411 times.
79345 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7671 {
7672
2/4
✓ Branch 0 taken 12934 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12934 times.
12934 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7673
2/4
✓ Branch 0 taken 12934 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12934 times.
12934 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7674 12934 }
7675
4/4
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 78919 times.
✓ Branch 2 taken 142 times.
✓ Branch 3 taken 284 times.
79345 if(g1 && g2)
7676 {
7677
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 9 times.
284 if(decorations.idCount(dTALLGRASS)==0)
7678 {
7679
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7680 9 }
7681 284 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+15)].attribytes[3];
7682
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
284 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7683 sfx(thesfx,pan((int32_t)x));
7684 284 }
7685 }
7686 79964 }
7687
7688
2/2
✓ Branch 0 taken 160811 times.
✓ Branch 1 taken 65191 times.
226002 if (get_bit(quest_rules, qr_SHALLOW_SENSITIVE))
7689 {
7690
16/26
✓ Branch 0 taken 14773 times.
✓ Branch 1 taken 146038 times.
✓ Branch 2 taken 14773 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14496 times.
✓ Branch 5 taken 277 times.
✓ Branch 6 taken 14496 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14368 times.
✓ Branch 9 taken 128 times.
✓ Branch 10 taken 14368 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 14368 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14368 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 14368 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 14368 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 14368 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 14368 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 14368 times.
160811 if (z == 0 && fakez == 0 && action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7691 {
7692
1/2
✓ Branch 0 taken 14368 times.
✗ Branch 1 not taken.
14385 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7693
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 14351 times.
14368 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7694
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7696 {
7697 if(decorations.idCount(dRIPPLES)==0)
7698 {
7699 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7700 }
7701 int32_t watercheck = iswaterex(FFORCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, false, false, true, true);
7702 if (combobuf[watercheck].usrflags&cflag2)
7703 {
7704 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7705 {
7706 onpassivedmg = true;
7707 if (!damageovertimeclk)
7708 {
7709 int32_t curhp = game->get_life();
7710 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7711 else game->set_life(vbound(game->get_life()+combobuf[watercheck].attributes[1]/10000L, 0, game->get_maxlife()));
7712 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7713 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
7714 {
7715 hclk = 48;
7716 hitdir = -1;
7717 action = gothit; FFCore.setHeroAction(gothit);
7718 }
7719 }
7720 if (combobuf[watercheck].attribytes[1] > 0)
7721 {
7722 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7723 else --damageovertimeclk;
7724 }
7725 else damageovertimeclk = 0;
7726 }
7727 else damageovertimeclk = 0;
7728 }
7729 else damageovertimeclk = 0;
7730 int32_t thesfx = combobuf[watercheck].attribytes[0];
7731 if (combobuf[watercheck].type != cSHALLOWWATER || !get_bit(quest_rules, qr_OLD_SHALLOW_SFX))
7732 {
7733 thesfx = combobuf[watercheck].attribytes[5];
7734 }
7735 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7736 sfx(thesfx,pan((int32_t)x));
7737 }
7738 14368 }
7739 160811 }
7740 else
7741 {
7742
7/8
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 65085 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 84 times.
✓ Branch 6 taken 65107 times.
✓ Branch 7 taken 84 times.
65191 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0 && fakez==0)
7743 {
7744
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1 times.
84 if(decorations.idCount(dRIPPLES)==0)
7745 {
7746
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7747 1 }
7748 84 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (combobuf[watercheck].usrflags&cflag2)
7750 {
7751 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7752 {
7753 onpassivedmg = true;
7754 if (!damageovertimeclk)
7755 {
7756 int32_t curhp = game->get_life();
7757 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7758 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7759 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7760 }
7761 if (combobuf[watercheck].attribytes[1] > 0)
7762 {
7763 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7764 else --damageovertimeclk;
7765 }
7766 else damageovertimeclk = 0;
7767 }
7768 else damageovertimeclk = 0;
7769 }
7770 84 else damageovertimeclk = 0;
7771 84 int32_t thesfx = combobuf[watercheck].attribytes[0];
7772
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7773 sfx(thesfx,pan((int32_t)x));
7774 84 }
7775 }
7776
7777
2/2
✓ Branch 0 taken 226001 times.
✓ Branch 1 taken 1 times.
226002 if(stomping)
7778 1 stomping = false;
7779
7780
2/2
✓ Branch 0 taken 225788 times.
✓ Branch 1 taken 214 times.
226002 if(getOnSideviewLadder())
7781 {
7782
4/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 214 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 214 times.
214 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7783 {
7784 setOnSideviewLadder(false);
7785 }
7786
2/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 214 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
214 else if(CANFORCEFACEUP)
7787 {
7788 setDir(up);
7789 }
7790 214 }
7791
7792
6/8
✓ Branch 0 taken 79964 times.
✓ Branch 1 taken 146038 times.
✓ Branch 2 taken 79836 times.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 79836 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 79836 times.
226002 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7793 {
7794
2/2
✓ Branch 0 taken 66411 times.
✓ Branch 1 taken 13425 times.
79836 if(!get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
7795 {
7796 13425 checkchest(cCHEST);
7797 13425 checkchest(cLOCKEDCHEST);
7798 13425 checkchest(cBOSSCHEST);
7799 13425 }
7800
2/2
✓ Branch 0 taken 66411 times.
✓ Branch 1 taken 13425 times.
79836 if(!get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
7801 {
7802 13425 checkchest(cLOCKBLOCK);
7803 13425 checkchest(cBOSSLOCKBLOCK);
7804 13425 }
7805 79836 }
7806 226002 checksigns();
7807 226002 checkgenpush();
7808
7809
4/4
✓ Branch 0 taken 77144 times.
✓ Branch 1 taken 148858 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 77054 times.
226002 if(isStanding(true) && fall == 0)
7810 {
7811
1/2
✓ Branch 0 taken 77054 times.
✗ Branch 1 not taken.
77054 if(extra_jump_count > 0)
7812 extra_jump_count = 0;
7813 77054 coyotetime = 0;
7814 77054 }
7815
2/2
✓ Branch 0 taken 147737 times.
✓ Branch 1 taken 1211 times.
148948 else if(coyotetime < 65535)
7816 {
7817 1211 ++coyotetime;
7818 1211 }
7819
1/2
✓ Branch 0 taken 226002 times.
✗ Branch 1 not taken.
226002 if(can_use_item(itype_hoverboots,i_hoverboots))
7820 {
7821 int32_t hoverid = current_item_id(itype_hoverboots);
7822 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7823 {
7824 if(hoverclk < 0) hoverclk = 0;
7825 hoverflags &= ~HOV_OUT;
7826 }
7827 }
7828 226002 bool platformfell2 = false;
7829 226002 int32_t gravity3 = (zinit.gravity2/100);
7830 226002 int32_t termv = (zinit.terminalv);
7831 226002 int32_t rocs = getRocsPressed();
7832
2/2
✓ Branch 0 taken 225035 times.
✓ Branch 1 taken 967 times.
226002 if (rocs != -1)
7833 {
7834 967 itemdata const& itm = itemsbuf[rocs];
7835
1/2
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
967 if (itm.flags & ITEM_FLAG2)
7836 {
7837 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
7838 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
7839 }
7840
1/2
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
967 if (itm.flags & ITEM_FLAG5)
7841 {
7842 termv = itm.misc4;
7843 if (fall > termv) fall = termv;
7844 }
7845 967 }
7846
2/2
✓ Branch 0 taken 6945 times.
✓ Branch 1 taken 219057 times.
226002 if(sideview_mode()) // Sideview gravity
7847 {
7848 //Handle falling through a platform
7849 6945 bool platformfell = false;
7850
4/4
✓ Branch 0 taken 3918 times.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 3903 times.
✓ Branch 3 taken 15 times.
6945 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7851 {
7852
7/8
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 8 times.
15 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7853 15 y+=1; //Fall down a pixel instantly, through the platform.
7854
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(fall < 0) fall = 0;
7855
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(jumping < 0) jumping = 0;
7856 15 platformfell2 = true;
7857 15 }
7858 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6945 times.
6945 if(!get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7860 {
7861
14/22
✓ Branch 0 taken 6055 times.
✓ Branch 1 taken 890 times.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 890 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 890 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 890 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 889 times.
✓ Branch 12 taken 889 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 889 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 889 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 889 times.
✓ Branch 20 taken 6944 times.
✓ Branch 21 taken 1 times.
7835 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7862
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 889 times.
✓ Branch 2 taken 874 times.
✓ Branch 3 taken 15 times.
904 || ((y+(fall/100)<=0) &&
7863 // Extra checks if Smart Screen Scrolling is enabled
7864
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7865 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7866 {
7867 1 fall = jumping = 0; // Bumped his head
7868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7869 y -= y.getInt()%8; //fix coords
7870 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7872 {
7873 1 checkdamagecombos(x+4, x+12, y-1, y-1);
7874 1 }
7875 1 }
7876 6945 }
7877 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7878
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 6945 times.
✓ Branch 2 taken 6945 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6945 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6945 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6945 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6945 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 214 times.
✓ Branch 13 taken 6731 times.
6945 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7879 {
7880
1/2
✓ Branch 0 taken 6731 times.
✗ Branch 1 not taken.
6731 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7881 //zprint2("ydif is: %d\n", ydiff);
7882 //zprint2("ydif is: %d\n", (int32_t)fall);
7883 6731 falling_oldy = y; // Stomp Boots-related variable
7884
5/8
✓ Branch 0 taken 1156 times.
✓ Branch 1 taken 5575 times.
✓ Branch 2 taken 1156 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1156 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6731 times.
✗ Branch 7 not taken.
6731 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7885 {
7886 ydiff -= (y.getInt()+ydiff)%16;
7887 }
7888
3/4
✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 5094 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1637 times.
6731 if(ydiff && !get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7889 {
7890
2/2
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 764 times.
1637 if(ydiff > 0)
7891 {
7892
2/2
✓ Branch 0 taken 831 times.
✓ Branch 1 taken 1607 times.
2438 for(auto q = 0; q < ydiff; ++q)
7893 {
7894
2/2
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 42 times.
1607 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7895 {
7896 42 ydiff = q;
7897 42 break;
7898 }
7899 1565 }
7900 873 }
7901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 764 times.
764 else if(ydiff < 0)
7902 {
7903
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 1492 times.
2256 for(auto q = 0; q > ydiff; --q)
7904 {
7905
1/2
✓ Branch 0 taken 1492 times.
✗ Branch 1 not taken.
2984 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1492 times.
1492 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7907 {
7908 ydiff = q;
7909 break;
7910 }
7911 1492 }
7912 764 }
7913 1637 }
7914 6731 y+=ydiff;
7915 6731 hs_starty+=ydiff;
7916
7917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6731 times.
6731 for(int32_t j=0; j<chainlinks.Count(); j++)
7918 {
7919 chainlinks.spr(j)->y+=ydiff;
7920 }
7921
7922
1/2
✓ Branch 0 taken 6731 times.
✗ Branch 1 not taken.
6731 if(Lwpns.idFirst(wHookshot)>-1)
7923 {
7924 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
7925 }
7926
7927
1/2
✓ Branch 0 taken 6731 times.
✗ Branch 1 not taken.
6731 if(Lwpns.idFirst(wHSHandle)>-1)
7928 {
7929 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
7930 }
7931 6731 }
7932
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
214 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
7933 {
7934 fall = hoverclk = jumping = 0;
7935 inair = false;
7936 hoverflags = 0;
7937 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
7938 {
7939 WalkflagInfo info;
7940 if (game->get_watergrav()<0)
7941 {
7942 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
7943 execute(info);
7944 }
7945 else
7946 {
7947 info = walkflag(x,y+15+2,2,down);
7948 execute(info);
7949 }
7950 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
7951 }
7952 }
7953 // Stop hovering/falling if you land on something.
7954 6945 bool needFall = false;
7955
7/8
✓ Branch 0 taken 3014 times.
✓ Branch 1 taken 3931 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6945 times.
✓ Branch 4 taken 4145 times.
✓ Branch 5 taken 2800 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 4132 times.
6945 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
7956 {
7957 4132 stop_item_sfx(itype_hoverboots);
7958
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
4132 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE)
7959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4132 times.
4132 && !getOnSideviewLadder()
7960 && (fall > 0 || get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON)))
7961 y-=(int32_t)y%8; //fix position
7962 4132 fall = hoverclk = jumping = 0;
7963 4132 inair = false;
7964 4132 hoverflags = 0;
7965
7966
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4132 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
7967 y = 160;
7968 4132 }
7969 // Stop hovering if you press down.
7970
3/6
✓ Branch 0 taken 2813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2813 times.
✗ Branch 5 not taken.
2813 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
7971 {
7972 stop_item_sfx(itype_hoverboots);
7973 hoverclk = -hoverclk;
7974 reset_ladder();
7975 fall = gravity3;
7976 inair = false;
7977 }
7978
8/10
✓ Branch 0 taken 2813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 870 times.
✓ Branch 3 taken 1943 times.
✓ Branch 4 taken 824 times.
✓ Branch 5 taken 46 times.
✓ Branch 6 taken 816 times.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 816 times.
2813 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell && !IsSideSwim())
7979 {
7980 816 zfix my = y + 4;
7981 816 needFall = true;
7982
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1135 times.
1182 for (zfix ty = y+1; ty < my; ++ty)
7983 {
7984 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
7985
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 769 times.
1135 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
7986 {
7987 769 y = ty;
7988
2/2
✓ Branch 0 taken 746 times.
✓ Branch 1 taken 23 times.
769 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
7989 {
7990
2/2
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 9 times.
746 if(!slopeid)
7991 9 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
7992 746 onplatid = 5;
7993 746 }
7994 769 needFall = false;
7995 769 break;
7996 }
7997 366 }
7998 816 }
7999 1997 else needFall = true;
8000 // Continue falling.
8001
8002
4/4
✓ Branch 0 taken 6824 times.
✓ Branch 1 taken 121 times.
✓ Branch 2 taken 4901 times.
✓ Branch 3 taken 1923 times.
6945 if(fall <= termv && needFall)
8003 {
8004 1923 inair = true;
8005
3/4
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1828 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 95 times.
1923 if(fall != 0 || hoverclk>0)
8006 1828 jumping++;
8007
8008 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1923 times.
1923 if(get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
8010 {
8011 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8012 || (y<=(bigHitbox?9:1) &&
8013 // Extra checks if Smart Screen Scrolling is enabled
8014 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8015 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8016 && fall < 0)
8017 {
8018 fall = jumping = 0; // Bumped his head
8019
8020 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8021 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8022 {
8023 checkdamagecombos(x+4, x+12, y-1, y-1);
8024 }
8025 }
8026 }
8027 else
8028 {
8029
8/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1923 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1923 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1923 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1923 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1923 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1923 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1923 times.
✓ Branch 14 taken 1923 times.
✗ Branch 15 not taken.
3846 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8030
3/4
✓ Branch 0 taken 1923 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 1904 times.
1923 || ((y<=0) &&
8031 // Extra checks if Smart Screen Scrolling is enabled
8032
2/6
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8033 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8034 && fall < 0)
8035 {
8036 fall = jumping = 0; // Bumped his head
8037 y -= y.getInt()%8; //fix coords
8038 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8039 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8040 {
8041 checkdamagecombos(x+4, x+12, y-1, y-1);
8042 }
8043 }
8044 }
8045
8046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1923 times.
1923 if(hoverclk > 0)
8047 {
8048 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8049 {
8050 --hoverclk;
8051 }
8052
8053 if(!hoverclk && !ladderx && !laddery)
8054 {
8055 fall += gravity3;
8056 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8057 }
8058 }
8059
5/12
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 885 times.
✓ Branch 2 taken 95 times.
✓ Branch 3 taken 943 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 95 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1923 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8060 {
8061 int32_t itemid = current_item_id(itype_hoverboots);
8062 if(hoverclk < 0)
8063 hoverclk = -hoverclk;
8064 else
8065 {
8066 fall = jumping = 0;
8067 if(itemsbuf[itemid].misc1)
8068 hoverclk = itemsbuf[itemid].misc1;
8069 else
8070 {
8071 hoverclk = 1;
8072 hoverflags |= HOV_INF;
8073 }
8074
8075
8076 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8077 }
8078 if(itemsbuf[itemid].wpn)
8079 decorations.add(new dHover(x, y, dHOVER, 0));
8080 }
8081
4/8
✓ Branch 0 taken 1923 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1923 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1923 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1923 times.
1923 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8082 {
8083 1923 fall += gravity3;
8084
8085 1923 }
8086 1923 }
8087 6945 }
8088 else // Topdown gravity
8089 {
8090
3/4
✓ Branch 0 taken 146038 times.
✓ Branch 1 taken 73019 times.
✓ Branch 2 taken 73019 times.
✗ Branch 3 not taken.
219057 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8091
3/4
✓ Branch 0 taken 146038 times.
✓ Branch 1 taken 73019 times.
✓ Branch 2 taken 73019 times.
✗ Branch 3 not taken.
219057 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8092
4/4
✓ Branch 0 taken 73019 times.
✓ Branch 1 taken 146038 times.
✓ Branch 2 taken 146038 times.
✓ Branch 3 taken 219057 times.
219057 if(z>0||fakez>0)
8093 {
8094
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292076 switch(action)
8095 {
8096 case swimming:
8097 {
8098 diveclk=0;
8099 action=walking; FFCore.setHeroAction(walking);
8100
8101 break;
8102 }
8103 case waterhold1:
8104 {
8105 action=landhold1; FFCore.setHeroAction(landhold1);
8106 break;
8107 }
8108
8109 case waterhold2:
8110 {
8111 action=landhold2; FFCore.setHeroAction(landhold2);
8112 break;
8113 }
8114
8115 default:
8116 break;
8117 }
8118 }
8119
8120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 219057 times.
219057 for(int32_t j=0; j<chainlinks.Count(); j++)
8121 {
8122 chainlinks.spr(j)->z=z;
8123 chainlinks.spr(j)->fakez=fakez;
8124 }
8125
8126
1/2
✓ Branch 0 taken 219057 times.
✗ Branch 1 not taken.
219057 if(Lwpns.idFirst(wHookshot)>-1)
8127 {
8128 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8129 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8130 }
8131
8132
1/2
✓ Branch 0 taken 219057 times.
✗ Branch 1 not taken.
219057 if(Lwpns.idFirst(wHSHandle)>-1)
8133 {
8134 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8135 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8136 }
8137
8138
3/4
✓ Branch 0 taken 73019 times.
✓ Branch 1 taken 146038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 73019 times.
219057 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8139 {
8140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 73019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
73019 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8141 {
8142
2/2
✓ Branch 0 taken 73018 times.
✓ Branch 1 taken 1 times.
73019 if(fall > 0)
8143 {
8144
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8145 sfx(WAV_ZN1SPLASH,x.getInt());
8146
8147 1 stomping = true;
8148 1 }
8149 73019 }
8150 73019 z = fall = 0;
8151
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 73019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
73019 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8152 {
8153 73019 jumping = 0;
8154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73019 times.
73019 if(check_pitslide(true) == -1)
8155 {
8156 73019 hoverclk = 0;
8157 73019 hoverflags = 0;
8158 73019 }
8159 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8160 {
8161 if(!--hoverclk)
8162 {
8163 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8164 }
8165 }
8166 73019 }
8167 73019 }
8168
3/4
✓ Branch 0 taken 73019 times.
✓ Branch 1 taken 146038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 73019 times.
219057 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8169 {
8170
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 73019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
73019 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8171 {
8172
1/2
✓ Branch 0 taken 73019 times.
✗ Branch 1 not taken.
73019 if(fakefall > 0)
8173 {
8174 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8175 sfx(WAV_ZN1SPLASH,x.getInt());
8176
8177 stomping = true;
8178 }
8179 73019 }
8180 73019 fakez = fakefall = 0;
8181
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 73019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
73019 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8182 {
8183 73019 jumping = 0;
8184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73019 times.
73019 if(check_pitslide(true) == -1)
8185 {
8186 73019 hoverclk = 0;
8187 73019 hoverflags = 0;
8188 73019 }
8189 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8190 {
8191 if(!--hoverclk)
8192 {
8193 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8194 }
8195 }
8196 73019 }
8197 73019 }
8198
7/10
✓ Branch 0 taken 73019 times.
✓ Branch 1 taken 146038 times.
✓ Branch 2 taken 73019 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73019 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 73019 times.
✓ Branch 7 taken 73019 times.
✓ Branch 8 taken 73019 times.
✗ Branch 9 not taken.
219057 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8199 {
8200
0/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
146038 if(fall != 0 || fakefall != 0 || hoverclk>0)
8201 jumping++;
8202
8203 if(hoverclk > 0)
8204 {
8205 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8206 {
8207 --hoverclk;
8208 }
8209
8210 if(!hoverclk)
8211 {
8212 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8213 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8214 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8215 }
8216 }
8217 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8218 {
8219 if(hoverclk < 0)
8220 hoverclk = -hoverclk;
8221 else
8222 {
8223 fall = 0;
8224 fakefall = 0;
8225 int32_t itemid = current_item_id(itype_hoverboots);
8226 if(itemsbuf[itemid].misc1)
8227 hoverclk = itemsbuf[itemid].misc1;
8228 else
8229 {
8230 hoverclk = 1;
8231 hoverflags |= HOV_INF;
8232 }
8233 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8234 }
8235 decorations.add(new dHover(x, y, dHOVER, 0));
8236 }
8237 else
8238 {
8239 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8240 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8241 }
8242 }
8243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73019 times.
73019 if (fakez<0) fakez = 0;
8244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73019 times.
73019 if (z<0) z = 0;
8245 }
8246
8247
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if(drunkclk)
8248 {
8249 --drunkclk;
8250 }
8251
8252
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if(lstunclock > 0)
8253 {
8254 // also cancel Hero's attack
8255 attackclk = 0;
8256
8257 if( FFCore.getHeroAction() != stunned )
8258 {
8259 tempaction=action; //update so future checks won't do this
8260 //action=freeze; //setting this makes the player invincible while stunned -V
8261 FFCore.setHeroAction(stunned);
8262 }
8263 --lstunclock;
8264 }
8265 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8266 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79964 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8268 {
8269 action=tempaction; FFCore.setHeroAction(tempaction);
8270 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8271 //action=none; FFCore.setHeroAction(none);
8272 }
8273
8274
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if( lbunnyclock > 0 )
8275 {
8276 --lbunnyclock;
8277 }
8278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
79964 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8279 {
8280 int32_t itemid = current_item_id(itype_pearl);
8281 if(itemid > -1)
8282 {
8283 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8284 lbunnyclock = 0;
8285 }
8286 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8287 {
8288 lbunnyclock = -1;
8289 }
8290 }
8291
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 else if(lbunnyclock == -1) //dmap-caused bunny effect
8292 {
8293 lbunnyclock = 0;
8294 }
8295
8296
9/16
✓ Branch 0 taken 79956 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 65183 times.
✓ Branch 3 taken 14773 times.
✓ Branch 4 taken 65183 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 65183 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 65183 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 180 times.
✓ Branch 15 taken 65003 times.
79964 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8297
1/2
✓ Branch 0 taken 65183 times.
✗ Branch 1 not taken.
65183 && action != gothit)
8298 {
8299
2/3
✓ Branch 0 taken 26411 times.
✓ Branch 1 taken 38592 times.
✗ Branch 2 not taken.
65003 switch(dir)
8300 {
8301 case up:
8302 case down:
8303 26411 x=(x.getInt()+4)&0xFFF8;
8304 26411 break;
8305
8306 case left:
8307 case right:
8308 38592 y=(y.getInt()+4)&0xFFF8;
8309 38592 break;
8310 }
8311 65003 }
8312
8313
3/4
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 79830 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 134 times.
79964 if((watch==true) && clockclk)
8314 {
8315 134 --clockclk;
8316
8317
1/2
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
134 if(!clockclk)
8318 {
8319 if(cheat_superman==false)
8320 {
8321 setClock(false);
8322 }
8323
8324 watch=false;
8325
8326 for(int32_t i=0; i<eMAXGUYS; i++)
8327 {
8328 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8329 {
8330 addenemy(0,0,i,0);
8331 }
8332 }
8333 }
8334 134 }
8335
8336
2/4
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79964 times.
79964 if(hookshot_frozen || switch_hooked)
8337 {
8338 if(hookshot_used || switch_hooked)
8339 {
8340 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8341 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8342
8343 if(pull_hero || switch_hooked)
8344 {
8345 if(hs_switcher || switch_hooked)
8346 {
8347 hs_fix = false;
8348 if(switchhookclk)
8349 {
8350 --switchhookclk;
8351 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8352 {
8353 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8354 reset_hookshot();
8355 else
8356 {
8357 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8358 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8359
8360 if(hooked_combopos > -1) //Switching combos
8361 {
8362 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8363 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8364 {
8365 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8366 for(int q = max_layer; q > -1; --q)
8367 {
8368 if(!(hooked_layerbits & (1<<q)))
8369 continue; //non-switching layer
8370 mapscr* scr = FFCore.tempScreens[q];
8371 newcombo const& cmb = combobuf[scr->data[targpos]];
8372 int32_t srcfl = scr->sflag[targpos];
8373 newcombo const& comb2 = combobuf[scr->data[plpos]];
8374 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8375 //{Check push status
8376 bool isFakePush = false;
8377 if(cmb.type == cSWITCHHOOK)
8378 {
8379 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8380 isFakePush = true;
8381 }
8382 bool isPush = isFakePush;
8383 if(!isPush) switch(srcfl)
8384 {
8385 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8386 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8387 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8388 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8389 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8390 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8391 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8392 isPush = true;
8393 }
8394 if(!isPush) switch(cmb.flag)
8395 {
8396 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8397 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8398 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8399 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8400 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8401 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8402 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8403 isPush = true;
8404 }
8405 if(srcfl==mfPUSHED) isPush = false;
8406 //}
8407 if(cmb.type == cSWITCHHOOK) //custom flags and such
8408 {
8409 if(cmb.usrflags&cflag3) //Breaks on swap
8410 {
8411 int32_t it = -1;
8412 int32_t thedropset = -1;
8413 if(cmb.usrflags&cflag4) //drop item
8414 {
8415 if(cmb.usrflags&cflag5)
8416 it = cmb.attribytes[2];
8417 else
8418 {
8419 it = select_dropitem(cmb.attribytes[2]);
8420 thedropset = cmb.attribytes[2];
8421 }
8422 }
8423
8424 breakable* br = new breakable(x, y, zfix(0),
8425 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8426 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8427 br->switch_hooked = true;
8428 decorations.add(br);
8429 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8430 hooked_undercombos[q] = -1;
8431
8432 if(cmb.usrflags&cflag6)
8433 {
8434 scr->data[targpos]++;
8435 }
8436 else
8437 {
8438 scr->data[targpos] = scr->undercombo;
8439 scr->cset[targpos] = scr->undercset;
8440 if(cmb.usrflags&cflag2)
8441 scr->sflag[targpos] = 0;
8442 }
8443 }
8444 else if(isPush)
8445 {
8446 //Simulate a block clicking into place
8447 movingblock mtemp;
8448 mtemp.clear();
8449 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8450 mtemp.dir = getPushDir(scr->sflag[targpos]);
8451 if(mtemp.dir < 0)
8452 mtemp.dir = getPushDir(cmb.flag);
8453 mtemp.clk = 1;
8454 if(isFakePush)
8455 mtemp.force_many = true;
8456 mtemp.animate(0);
8457 if((mtemp.bhole || mtemp.trigger)
8458 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8459 || comb2.flag == mfBLOCKTRIGGER
8460 || comb2.flag == mfBLOCKHOLE))
8461 {
8462 scr->data[targpos] = scr->undercombo;
8463 scr->cset[targpos] = scr->undercset;
8464 scr->sflag[targpos] = 0;
8465 }
8466 else
8467 {
8468 scr->data[targpos] = c;
8469 scr->cset[targpos] = cs;
8470 if(cmb.usrflags&cflag2)
8471 scr->sflag[targpos] = fl;
8472 else
8473 scr->sflag[targpos] = 0;
8474 }
8475 }
8476 else
8477 {
8478 scr->data[plpos] = scr->data[targpos];
8479 scr->cset[plpos] = scr->cset[targpos];
8480 if(cmb.usrflags&cflag2)
8481 scr->sflag[plpos] = scr->sflag[targpos];
8482 scr->data[targpos] = c;
8483 scr->cset[targpos] = cs;
8484 if(cmb.usrflags&cflag2)
8485 scr->sflag[targpos] = fl;
8486 }
8487 }
8488 else if(isCuttableType(cmb.type)) //Break and drop effects
8489 {
8490 int32_t breakcs = scr->cset[targpos];
8491 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8492 {
8493 scr->data[targpos]++;
8494 }
8495 else
8496 {
8497 scr->data[targpos] = scr->undercombo;
8498 scr->cset[targpos] = scr->undercset;
8499 scr->sflag[targpos] = 0;
8500 }
8501
8502 int32_t it = -1;
8503 int32_t thedropset = -1;
8504 if(isCuttableItemType(cmb.type)) //Drop an item
8505 {
8506 if ( (cmb.usrflags&cflag2) )
8507 {
8508 if(cmb.usrflags&cflag11)
8509 it = cmb.attribytes[1];
8510 else
8511 {
8512 it = select_dropitem(cmb.attribytes[1]);
8513 thedropset = cmb.attribytes[1];
8514 }
8515 }
8516 else
8517 {
8518 it = select_dropitem(12);
8519 thedropset = 12;
8520 }
8521 }
8522
8523 byte breaksfx = 0;
8524 if(get_bit(quest_rules,qr_MORESOUNDS)) //SFX
8525 {
8526 if (cmb.usrflags&cflag3)
8527 {
8528 breaksfx = cmb.attribytes[2];
8529 }
8530 else if(isBushType(cmb.type)
8531 || isFlowersType(cmb.type)
8532 || isGrassType(cmb.type))
8533 {
8534 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8535 }
8536 }
8537
8538 //Clipping sprite
8539 int16_t decotype = (cmb.usrflags & cflag1) ?
8540 ((cmb.usrflags & cflag10)
8541 ? (cmb.attribytes[0])
8542 : (-1))
8543 : (0);
8544 if(decotype > 3) decotype = 0;
8545 if(!decotype)
8546 decotype = (isBushType(cmb.type) ? 1
8547 : (isFlowersType(cmb.type) ? 2
8548 : (isGrassType(cmb.type) ? 3
8549 : ((cmb.usrflags & cflag1) ? -1
8550 : -2))));
8551
8552 breakable* br = new breakable(x, y, zfix(0),
8553 cmb, breakcs, it, thedropset, breaksfx,
8554 decotype, cmb.attribytes[0], switchhookclk);
8555 br->switch_hooked = true;
8556 decorations.add(br);
8557 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8558 hooked_undercombos[q] = -1;
8559 }
8560 else //Unknown type, just swap combos.
8561 {
8562 if(isPush)
8563 {
8564 //Simulate a block clicking into place
8565 movingblock mtemp;
8566 mtemp.clear();
8567 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8568 mtemp.dir = getPushDir(scr->sflag[targpos]);
8569 if(mtemp.dir < 0)
8570 mtemp.dir = getPushDir(cmb.flag);
8571 mtemp.clk = 1;
8572 mtemp.animate(0);
8573 if(mtemp.bhole || mtemp.trigger)
8574 {
8575 scr->data[targpos] = scr->undercombo;
8576 scr->cset[targpos] = scr->undercset;
8577 scr->sflag[targpos] = 0;
8578 }
8579 else
8580 {
8581 scr->data[targpos] = c;
8582 scr->cset[targpos] = cs;
8583 scr->sflag[targpos] = 0;
8584 }
8585 }
8586 else
8587 {
8588 scr->data[plpos] = scr->data[targpos];
8589 scr->cset[plpos] = scr->cset[targpos];
8590 scr->data[targpos] = c;
8591 scr->cset[targpos] = cs;
8592 }
8593 }
8594 }
8595 if(switchhook_cost_item > -1)
8596 paymagiccost(switchhook_cost_item);
8597 zfix tx = x, ty = y;
8598 //Position the player at the combo
8599 x = COMBOX(targpos);
8600 y = COMBOY(targpos);
8601 dir = oppositeDir[dir];
8602 if(w && hw)
8603 {
8604 //Calculate chain shift
8605 zfix dx = (x-tx);
8606 zfix dy = (y-ty);
8607 if(w->dir < 4)
8608 {
8609 if(w->dir & 2)
8610 dx = 0;
8611 else dy = 0;
8612 }
8613 //Position the hook head at the handle
8614 w->x = hw->x + dx;
8615 w->y = hw->y + dy;
8616 w->dir = oppositeDir[w->dir];
8617 w->doAutoRotate(true);
8618 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8619 w->flip ^= hflip;
8620 //Position the handle appropriately
8621 hw->x = x-(hw->x-tx);
8622 hw->y = y-(hw->y-ty);
8623 hw->dir = oppositeDir[hw->dir];
8624 hw->doAutoRotate(true);
8625 hw->flip ^= hflip;
8626 //Move chains
8627 for(int32_t j=0; j<chainlinks.Count(); j++)
8628 {
8629 chainlinks.spr(j)->x += dx;
8630 chainlinks.spr(j)->y += dy;
8631 }
8632 }
8633 hooked_combopos = plpos; //flip positions
8634 }
8635 else reset_hookshot();
8636 }
8637 else if(switching_object) //Switching an object
8638 {
8639 if(switchhook_cost_item > -1)
8640 paymagiccost(switchhook_cost_item);
8641 zfix tx = x, ty = y;
8642 //Position the player at the object
8643 x = switching_object->x;
8644 y = switching_object->y;
8645 dir = oppositeDir[dir];
8646 //Position the object at the player
8647 switching_object->x = tx;
8648 switching_object->y = ty;
8649 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8650 switching_object->dir = oppositeDir[switching_object->dir];
8651 solid_update(false);
8652 switching_object->solid_update(false);
8653 if(item* it = dynamic_cast<item*>(switching_object))
8654 {
8655 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8656 {
8657 movefairynew2(it->x, it->y, *it);
8658 }
8659 }
8660 if(w && hw) //!TODO No fucking clue if diagonals work
8661 {
8662 //Calculate chain shift
8663 zfix dx = (x-tx);
8664 zfix dy = (y-ty);
8665 if(w->dir < 4)
8666 {
8667 if(w->dir & 2)
8668 dx = 0;
8669 else dy = 0;
8670 }
8671 //Position the hook head at the handle
8672 w->x = hw->x + dx;
8673 w->y = hw->y + dy;
8674 w->dir = oppositeDir[w->dir];
8675 w->doAutoRotate(true);
8676 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8677 w->flip ^= hflip;
8678 w->solid_update(false);
8679 //Position the handle appropriately
8680 hw->x = x-(hw->x-tx);
8681 hw->y = y-(hw->y-ty);
8682 hw->dir = oppositeDir[hw->dir];
8683 hw->doAutoRotate(true);
8684 hw->flip ^= hflip;
8685 hw->solid_update(false);
8686 //Move chains
8687 for(int32_t j=0; j<chainlinks.Count(); j++)
8688 {
8689 chainlinks.spr(j)->x += dx;
8690 chainlinks.spr(j)->y += dy;
8691 }
8692 }
8693 }
8694 }
8695 }
8696 else if(!switchhookclk)
8697 {
8698 reset_hookshot();
8699 }
8700 }
8701 else reset_hookshot();
8702 }
8703 else
8704 {
8705 sprite *t;
8706 int32_t i;
8707
8708 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8709 {
8710 /* do nothing */
8711 }
8712
8713 t = Lwpns.spr(i);
8714
8715 for(i=0; i<Lwpns.Count(); i++)
8716 {
8717 sprite *s = Lwpns.spr(i);
8718
8719 if(s->id==wHookshot)
8720 {
8721 if (abs((s->y) - y) >= 1)
8722 {
8723 if((s->y)>y)
8724 {
8725 y+=4;
8726
8727 if(Lwpns.idFirst(wHSHandle)!=-1)
8728 {
8729 t->y+=4;
8730 }
8731
8732 hs_starty+=4;
8733 }
8734
8735 if((s->y)<y)
8736 {
8737 y-=4;
8738
8739 if(Lwpns.idFirst(wHSHandle)!=-1)
8740 {
8741 t->y-=4;
8742 }
8743
8744 hs_starty-=4;
8745 }
8746 }
8747 else
8748 {
8749 y = (s->y);
8750 }
8751 if (abs((s->x) - x) >= 1)
8752 {
8753 if((s->x)>x)
8754 {
8755 x+=4;
8756
8757 if(Lwpns.idFirst(wHSHandle)!=-1)
8758 {
8759 t->x+=4;
8760 }
8761
8762 hs_startx+=4;
8763 }
8764
8765 if((s->x)<x)
8766 {
8767 x-=4;
8768
8769 if(Lwpns.idFirst(wHSHandle)!=-1)
8770 {
8771 t->x-=4;
8772 }
8773
8774 hs_startx-=4;
8775 }
8776 }
8777 else
8778 {
8779 x = (s->x);
8780 }
8781 }
8782 }
8783 }
8784 }
8785 }
8786 else
8787 {
8788 Lwpns.del(Lwpns.idFirst(wHSHandle));
8789 reset_hookshot();
8790 }
8791
8792 if(hs_fix)
8793 {
8794 if(dir==up)
8795 {
8796 y=int32_t(y+7)&0xF0;
8797 }
8798
8799 if(dir==down)
8800 {
8801 y=int32_t(y+7)&0xF0;
8802 }
8803
8804 if(dir==left)
8805 {
8806 x=int32_t(x+7)&0xF0;
8807 }
8808
8809 if(dir==right)
8810 {
8811 x=int32_t(x+7)&0xF0;
8812 }
8813
8814 hs_fix=false;
8815 }
8816
8817 }
8818
8819
2/2
✓ Branch 0 taken 1784 times.
✓ Branch 1 taken 78180 times.
79964 if(!get_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8820 {
8821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78180 times.
78180 if(DrunkrLbtn())
8822 selectNextBWpn(SEL_LEFT);
8823
2/2
✓ Branch 0 taken 78178 times.
✓ Branch 1 taken 2 times.
78180 else if(DrunkrRbtn())
8824 2 selectNextBWpn(SEL_RIGHT);
8825 78180 }
8826
4/4
✓ Branch 0 taken 1784 times.
✓ Branch 1 taken 78180 times.
✓ Branch 2 taken 1220 times.
✓ Branch 3 taken 564 times.
79964 if (get_bit(quest_rules, qr_SELECTAWPN) && get_bit(quest_rules, qr_USE_EX1_EX2_INVENTORYSWAP))
8827 {
8828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 564 times.
564 if (rEx3btn())
8829 selectNextAWpn(SEL_LEFT);
8830
2/2
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 1 times.
564 else if (rEx4btn())
8831 1 selectNextAWpn(SEL_RIGHT);
8832 564 }
8833
8834
2/2
✓ Branch 0 taken 79960 times.
✓ Branch 1 taken 4 times.
79964 if(rPbtn())
8835 {
8836
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8837 1 onViewMap();
8838 4 }
8839
2/2
✓ Branch 0 taken 22166 times.
✓ Branch 1 taken 79964 times.
102130 for(int32_t i=0; i<Lwpns.Count(); i++)
8840 {
8841 22166 weapon *w = ((weapon*)Lwpns.spr(i));
8842
8843
4/6
✓ Branch 0 taken 22166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17949 times.
✓ Branch 3 taken 4217 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17949 times.
22166 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8844 4217 addsparkle(i);
8845 22166 }
8846
8847
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if(Lwpns.idCount(wPhantom))
8848 {
8849 addsparkle2(pDINSFIREROCKET,pDINSFIREROCKETTRAIL);
8850 addsparkle2(pDINSFIREROCKETRETURN,pDINSFIREROCKETTRAILRETURN);
8851 addsparkle2(pNAYRUSLOVEROCKET1,pNAYRUSLOVEROCKETTRAIL1);
8852 addsparkle2(pNAYRUSLOVEROCKET2,pNAYRUSLOVEROCKETTRAIL2);
8853 addsparkle2(pNAYRUSLOVEROCKETRETURN1,pNAYRUSLOVEROCKETTRAILRETURN1);
8854 addsparkle2(pNAYRUSLOVEROCKETRETURN2,pNAYRUSLOVEROCKETTRAILRETURN2);
8855 }
8856
8857 // Pay magic cost for Byrna beams
8858
8859 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8860
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if(Lwpns.idCount(wCByrna))
8861 {
8862 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8863 int32_t itemid = ew->parentitem;
8864
8865 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8866 {
8867 for(int32_t i=0; i<Lwpns.Count(); i++)
8868 {
8869 weapon *w = ((weapon*)Lwpns.spr(i));
8870
8871 if(w->id==wCByrna)
8872 {
8873 w->dead=1;
8874 }
8875
8876 }
8877 //kill the sound effect for the orbits -Z 14FEB2019
8878 stop_sfx(itemsbuf[itemid].usesound);
8879 }
8880 else paymagiccost(itemid);
8881 }
8882
8883
2/4
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79964 times.
✗ Branch 3 not taken.
79964 if(z==0&&fakez==0)
8884 {
8885 79964 switchblock_z = 0;
8886
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if(switchblock_offset)
8887 {
8888 switchblock_offset=false;
8889 yofs += 8;
8890 }
8891 79964 }
8892
2/2
✓ Branch 0 taken 6945 times.
✓ Branch 1 taken 73019 times.
79964 if(!isSideViewHero())
8893 {
8894 73019 int32_t tx = x.getInt()+8,
8895 73019 ty = y.getInt()+8;//(bigHitbox?8:12);
8896
2/4
✓ Branch 0 taken 73019 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73019 times.
73019 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8897 {
8898
2/2
✓ Branch 0 taken 73019 times.
✓ Branch 1 taken 219057 times.
292076 for(int32_t q = 0; q < 3; ++q)
8899 {
8900
4/4
✓ Branch 0 taken 146038 times.
✓ Branch 1 taken 73019 times.
✓ Branch 2 taken 14497 times.
✓ Branch 3 taken 131541 times.
219057 if(q && !tmpscr2[q-1].valid) continue;
8901 87516 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
8902
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 87516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
87516 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
8903 int32_t b = 1;
8904 if(tx&8) b <<= 2;
8905 if(ty&8) b <<= 1;
8906 b |= (b<<4); //check equivalent effect flag too
8907 if((cmb.walk&b)==b) //solid and effecting
8908 {
8909 if(z==0&&fakez==0)
8910 {
8911 if(cmb.usrflags&cflag10)
8912 {
8913 if(!switchblock_offset)
8914 {
8915 switchblock_offset=true;
8916 yofs -= 8;
8917 }
8918 }
8919 else
8920 {
8921 if(switchblock_offset)
8922 {
8923 switchblock_offset=false;
8924 yofs += 8;
8925 }
8926 }
8927 }
8928 if(cmb.attributes[2]>0 && switchblock_z>=0)
8929 {
8930 if(z==0&&fakez==0)
8931 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
8932 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
8933 {
8934 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
8935 }
8936 }
8937 else switchblock_z = -1;
8938 break;
8939 }
8940 }
8941 73019 }
8942 73019 }
8943 79964 ClearhitHeroUIDs(); //clear them before we advance.
8944 79964 checkhit();
8945
8946 79964 bool forcedeath = dying_flags&DYING_FORCED;
8947 79964 bool norev = (dying_flags&DYING_NOREV);
8948
2/6
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79964 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79964 if(forcedeath || (game->get_life()<=0 && !immortal))
8949 {
8950 if(forcedeath)
8951 game->set_life(0);
8952 if(!norev)
8953 for(size_t slot = 0; slot < 256; ++slot)
8954 {
8955 if(size_t bind = game->get_bottle_slot(slot))
8956 {
8957 bottletype const* bt = &QMisc.bottle_types[bind-1];
8958 if(!(bt->flags&BTFLAG_AUTOONDEATH))
8959 continue;
8960 word toFill[3] = { 0 };
8961 for(size_t q = 0; q < 3; ++q)
8962 {
8963 char c = bt->counter[q];
8964 if(c > -1)
8965 {
8966 if(bt->flags & (1<<q))
8967 {
8968 toFill[q] = (bt->amount[q]==100)
8969 ? game->get_maxcounter(c)
8970 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
8971 }
8972 else toFill[q] = bt->amount[q];
8973 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
8974 {
8975 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
8976 }
8977 }
8978 }
8979 if(bt->flags & BTFLAG_CURESWJINX)
8980 {
8981 swordclk = 0;
8982 verifyAWpn();
8983 }
8984 if(bt->flags & BTFLAG_CUREITJINX)
8985 itemclk = 0;
8986 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
8987 {
8988 int32_t itemid = find_bottle_for_slot(slot,true);
8989 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
8990 if(itemid > -1)
8991 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8992 for(size_t q = 0; q < 20; ++q)
8993 do_death_refill_waitframe();
8994 double inc = max/60.0; //1 second
8995 double xtra[3]{ 0 };
8996 for(size_t q = 0; q < 60; ++q)
8997 {
8998 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
8999 sfx(QMisc.miscsfx[sfxREFILL]);
9000 for(size_t j = 0; j < 3; ++j)
9001 {
9002 xtra[j] += inc;
9003 word f = floor(xtra[j]);
9004 xtra[j] -= f;
9005 if(toFill[j] > f)
9006 {
9007 toFill[j] -= f;
9008 game->change_counter(f,bt->counter[j]);
9009 }
9010 else if(toFill[j])
9011 {
9012 game->change_counter(toFill[j],bt->counter[j]);
9013 toFill[j] = 0;
9014 }
9015 }
9016 do_death_refill_waitframe();
9017 }
9018 for(size_t j = 0; j < 3; ++j)
9019 {
9020 if(toFill[j])
9021 {
9022 game->change_counter(toFill[j],bt->counter[j]);
9023 toFill[j] = 0;
9024 }
9025 }
9026 for(size_t q = 0; q < 20; ++q)
9027 do_death_refill_waitframe();
9028 }
9029 game->set_bottle_slot(slot,bt->next_type);
9030 if(game->get_life() > 0)
9031 {
9032 dying_flags = 0;
9033 forcedeath = false;
9034 break; //Revived! Stop drinking things...
9035 }
9036 }
9037 }
9038
9039 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9040 {
9041 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9042 {
9043 // So scripts can have one frame to handle hp zero events
9044 if(norev || false == (last_hurrah = !last_hurrah))
9045 {
9046 dying_flags = 0;
9047 drunkclk=0;
9048 lstunclock = 0;
9049 is_conveyor_stunned = 0;
9050 FFCore.setHeroAction(dying);
9051 FFCore.deallocateAllArrays(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME);
9052 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE);
9053 ALLOFF(true,true);
9054 GameFlags |= GAMEFLAG_NO_F6;
9055 if(!debug_enabled)
9056 {
9057 Paused=false;
9058 }
9059 if(!get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9060 {
9061 FFCore.runOnDeathEngine();
9062 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9063 }
9064 Playing = false;
9065 heroDeathAnimation();
9066 if(get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9067 {
9068 Playing = true;
9069 FFCore.runOnDeathEngine();
9070 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9071 Playing = false;
9072 }
9073 GameFlags &= ~GAMEFLAG_NO_F6;
9074 ALLOFF(true,true);
9075 return true;
9076 }
9077 }
9078 }
9079 else //2.50.x
9080 {
9081 // So scripts can have one frame to handle hp zero events
9082 if(false == (last_hurrah = !last_hurrah))
9083 {
9084 drunkclk=0;
9085 heroDeathAnimation();
9086
9087 return true;
9088 }
9089 }
9090 }
9091 79964 else last_hurrah=false;
9092
9093
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 79664 times.
79964 if(swordclk>0)
9094 {
9095 300 --swordclk;
9096
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 2 times.
300 if(!swordclk) verifyAWpn();
9097 300 }
9098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
79964 if(itemclk>0)
9099 --itemclk;
9100
9101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
79964 if(inwallm)
9102 {
9103 attackclk=0;
9104 herostep();
9105
9106 if(CarryHero()==false)
9107 restart_level();
9108
9109 solid_update(false);
9110 return false;
9111 }
9112
9113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
79964 if(ewind_restart)
9114 {
9115 attackclk=0;
9116 restart_level();
9117 xofs=0;
9118 action=none; FFCore.setHeroAction(none);
9119 ewind_restart=false;
9120 solid_update(false);
9121 return false;
9122 }
9123
9124
2/2
✓ Branch 0 taken 79963 times.
✓ Branch 1 taken 1 times.
79964 if(hopclk)
9125 {
9126 1 action=hopping; FFCore.setHeroAction(hopping);
9127 1 }
9128
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if(fallclk)
9129 {
9130 action=falling; FFCore.setHeroAction(falling);
9131 }
9132
9133 79964 handle_passive_buttons();
9134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
79964 if(liftclk)
9135 {
9136 if(lift_wpn)
9137 {
9138 action=lifting; FFCore.setHeroAction(lifting);
9139 }
9140 else
9141 {
9142 liftclk = 0;
9143 tliftclk = 0;
9144 }
9145 }
9146
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 else if(lift_wpn)
9147 {
9148 handle_lift(false);
9149 }
9150
9151
9152 // get user input or do other animation
9153 79964 freeze_guys=false; // reset this flag, set it again if holding
9154
9155
11/16
✓ Branch 0 taken 78534 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 78404 times.
✓ Branch 3 taken 130 times.
✓ Branch 4 taken 78404 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 78404 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 78404 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 78404 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 78321 times.
✓ Branch 13 taken 83 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 78321 times.
79964 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9156 {
9157 holdclk=0;
9158 }
9159
9160 79964 active_shield_id = refreshActiveShield();
9161 79964 bool sh = active_shield_id > -1;
9162 79964 itemdata const& shield = itemsbuf[active_shield_id];
9163 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9164 79964 shield_forcedir = -1;
9165
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79964 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9166 {
9167 shield_forcedir = dir;
9168 }
9169
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if(sh != shield_active) //Toggle active shield on/off
9170 {
9171 shield_active = sh;
9172 if(sh) //Toggle active shield on
9173 {
9174 sfx(shield.usesound2); //'Activate' sfx
9175 }
9176 }
9177
9178 79964 bool isthissolid = false;
9179
7/12
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 2331 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1560 times.
✓ Branch 6 taken 75460 times.
✓ Branch 7 taken 208 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
79964 switch(action)
9180 {
9181 case gothit:
9182
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 198 times.
208 if(attackclk)
9183
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
13 if(!doattack())
9184 {
9185 3 attackclk=spins=0;
9186 3 tapping=false;
9187 3 }
9188
9189 208 break;
9190
9191 case drowning:
9192 case lavadrowning:
9193 case sidedrowning:
9194 {
9195 128 herostep(); // maybe this line should be elsewhere?
9196
9197 //!DROWN
9198 // Helpful comment to find drowning -Dimi
9199
9200 128 drop_liftwpn();
9201
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 2 times.
128 if(--drownclk==0)
9202 {
9203 2 action=none; FFCore.setHeroAction(none);
9204 2 int32_t water = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9205 2 int32_t damage = combobuf[water].attributes[0]/10000L;
9206 //if (damage == 0 && !(combobuf[water].usrflags&cflag7)) damage = (game->get_hp_per_heart()/4);
9207 2 drownCombo = 0;
9208
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (combobuf[water].type != cWATER) damage = 4;
9209 2 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9210 2 go_respawn_point();
9211 2 hclk=48;
9212 2 }
9213
9214 128 break;
9215 }
9216 case falling:
9217 {
9218 herostep();
9219 pitfall();
9220 break;
9221 }
9222 case freeze:
9223 case sideswimfreeze:
9224 case scrolling:
9225 2331 break;
9226
9227 case casting:
9228 case sideswimcasting:
9229 {
9230 if(magicitem==-1)
9231 {
9232 action=none; FFCore.setHeroAction(none);
9233 }
9234
9235 break;
9236 }
9237 case landhold1:
9238 case landhold2:
9239 {
9240
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1548 times.
1560 if(--holdclk <= 0)
9241 {
9242 //restart music
9243
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
12 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9244 playLevelMusic();
9245
9246 12 action=none; FFCore.setHeroAction(none);
9247 12 }
9248 else
9249 1548 freeze_guys=true;
9250
9251 1560 break;
9252 }
9253 case waterhold1:
9254 case waterhold2:
9255 case sidewaterhold1:
9256 case sidewaterhold2:
9257 {
9258 diveclk=0;
9259
9260 if(--holdclk <= 0)
9261 {
9262 //restart music
9263 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9264 playLevelMusic();
9265
9266 SetSwim();
9267 }
9268 else
9269 freeze_guys=true;
9270
9271 break;
9272 }
9273 case hopping:
9274 {
9275
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if(DRIEDLAKE)
9276 {
9277 action=none; FFCore.setHeroAction(none);
9278 hopclk = 0;
9279 diveclk = 0;
9280 break;
9281 }
9282
9283 1 do_hopping();
9284 1 break;
9285 }
9286 case inwind:
9287 {
9288 int32_t i=Lwpns.idFirst(wWind);
9289
9290 if(i<0)
9291 {
9292 bool exit=false;
9293
9294 if(whirlwind==255)
9295 {
9296 exit=true;
9297 }
9298 else if(y<=0 && dir==up) y=-1;
9299 else if(y>=160 && dir==down) y=161;
9300 else if(x<=0 && dir==left) x=-1;
9301 else if(x>=240 && dir==right) x=241;
9302 else exit=true;
9303
9304 if(exit)
9305 {
9306 action=none; FFCore.setHeroAction(none);
9307 xofs=0;
9308 whirlwind=0;
9309 lstep=0;
9310 if ( dontdraw < 2 ) dontdraw=0;
9311 set_respawn_point();
9312 }
9313 }
9314 /*
9315 else if (((weapon*)Lwpns.spr(i))->dead==1)
9316 {
9317 whirlwind=255;
9318 }
9319 */
9320 else
9321 {
9322 x=Lwpns.spr(i)->x;
9323 y=Lwpns.spr(i)->y;
9324 dir=Lwpns.spr(i)->dir;
9325 }
9326 }
9327 break;
9328 case lifting:
9329 handle_lift();
9330 break;
9331
9332 case sideswimming:
9333 case sideswimattacking:
9334 case sideswimhit:
9335 case swimhit:
9336 case swimming:
9337 {
9338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 if(DRIEDLAKE)
9339 {
9340 action=none; FFCore.setHeroAction(none);
9341 hopclk=0;
9342 break;
9343 }
9344
9345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
276 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9346
9347
3/4
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 138 times.
276 if((frame&1) && !shouldbreak)
9348 138 herostep();
9349
9350
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 276 times.
✗ Branch 5 not taken.
552 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9351
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 276 times.
276 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9352
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 276 times.
276 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 276 times.
276 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9354
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
276 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9355 {
9356
2/4
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
552 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9357
2/4
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
276 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9358 {
9359 hopclk=0;
9360 diveclk=0;
9361 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9362 else {action=attacking; FFCore.setHeroAction(attacking);}
9363 hopdir=-1;
9364 }
9365 276 }
9366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
276 if (shouldbreak) break;
9367
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
276 if (action == swimming || action == sideswimming || action == sideswimattacking)
9368 {
9369 276 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
276 if (combobuf[watercheck].usrflags&cflag2)
9371 {
9372 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9373 {
9374 onpassivedmg = true;
9375 if (damageovertimeclk == 0)
9376 {
9377 int32_t curhp = game->get_life();
9378 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9379 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9380 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9381 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9382 {
9383 hclk = 48;
9384 hitdir = -1;
9385 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9386 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9387 }
9388 }
9389 if (combobuf[watercheck].attribytes[1] > 0)
9390 {
9391 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9392 else --damageovertimeclk;
9393 }
9394 else damageovertimeclk = 0;
9395 }
9396 else damageovertimeclk = 0;
9397 }
9398 276 else damageovertimeclk = 0;
9399 //combobuf[watercheck].attributes[0]
9400 276 }
9401
9402 276 }
9403 [[fallthrough]];
9404 default:
9405 75736 movehero(); // call the main movement routine
9406 75736 }
9407
9408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79964 if(shield_forcedir > -1 && action != rafting)
9409 dir = shield_forcedir;
9410
9411
2/2
✓ Branch 0 taken 66975 times.
✓ Branch 1 taken 12989 times.
79964 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
9412 12989 set_respawn_point(false); //Keep the 'last safe location' updated!
9413
9414 // check for ladder removal
9415
2/2
✓ Branch 0 taken 14773 times.
✓ Branch 1 taken 65191 times.
79964 if(diagonalMovement)
9416 {
9417
1/2
✓ Branch 0 taken 14773 times.
✗ Branch 1 not taken.
14773 if(ladderx+laddery)
9418 {
9419 if(ladderdir==up)
9420 {
9421 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9422 {
9423 reset_ladder();
9424 }
9425 }
9426 else
9427 {
9428 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9429 {
9430 reset_ladder();
9431 }
9432 }
9433 }
9434 14773 }
9435 else
9436 {
9437
3/4
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 64668 times.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
65191 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9438 {
9439 65191 reset_ladder();
9440 65191 }
9441 }
9442
9443
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 79939 times.
79964 if(ilswim)
9444 25 landswim++;
9445 79939 else landswim=0;
9446
9447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
79964 if(hopclk!=0xFF) ilswim=false;
9448
9449
3/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 79814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 150 times.
79964 if((!loaded_guys) && (frame - newscr_clk >= 1))
9450 {
9451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(tmpscr->room==rGANON)
9452 {
9453 ganon_intro();
9454 }
9455 else
9456 {
9457 150 loadguys();
9458 }
9459 150 }
9460
9461
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 79780 times.
79964 if(frame - newscr_clk >= 2)
9462 {
9463 79780 loadenemies();
9464 79780 }
9465
9466 // check lots of other things
9467 79964 checkscroll();
9468
9469
6/8
✓ Branch 0 taken 79959 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 79833 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 79833 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 79833 times.
79964 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9470 {
9471 79833 checkspecial();
9472 79833 checkitems();
9473 79833 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9474
2/2
✓ Branch 0 taken 13427 times.
✓ Branch 1 taken 66406 times.
79833 if(get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
9475 {
9476 66406 oldchecklockblock();
9477 66406 oldcheckbosslockblock();
9478 66406 }
9479
2/2
✓ Branch 0 taken 13427 times.
✓ Branch 1 taken 66406 times.
79833 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
9480 {
9481 66406 oldcheckchest(cCHEST);
9482 66406 oldcheckchest(cLOCKEDCHEST);
9483 66406 oldcheckchest(cBOSSCHEST);
9484 66406 }
9485 79833 checkpushblock();
9486 79833 checkswordtap();
9487
9488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79833 times.
79833 if(hookshot_frozen==false)
9489 {
9490 79833 checkspecial2(&lsave);
9491 79833 }
9492
9493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79833 times.
79833 if(action==won)
9494 {
9495 return true;
9496 }
9497 79833 }
9498
9499 // Somehow Hero was displaced from the fairy flag...
9500
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 79881 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79964 if(fairyclk && action != freeze && action != sideswimfreeze)
9501 {
9502 fairyclk = holdclk = refill_why = 0;
9503 }
9504
9505
3/4
✓ Branch 0 taken 79959 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 79959 times.
✗ Branch 3 not taken.
79964 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9506 {
9507 tmpscr->timedwarptics--;
9508
9509 if(tmpscr->timedwarptics==0)
9510 {
9511 activated_timed_warp=true;
9512
9513 if(tmpscr->flags4 & fTIMEDDIRECT)
9514 {
9515 didpit=true;
9516 pitx=x;
9517 pity=y;
9518 }
9519
9520 int32_t index2 = 0;
9521
9522 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9523
9524 sdir = dir;
9525 dowarp(1,index2);
9526 }
9527 }
9528
9529 79964 bool awarp = false;
9530 //!DIMI: Global Combo Effects (AUTO STUFF)
9531
2/2
✓ Branch 0 taken 128047 times.
✓ Branch 1 taken 79964 times.
208011 for(auto& p : slopes)
9532 {
9533 128047 slope_object& s = p.second;
9534 128047 s.updateslope(); //sets old x/y poses
9535 }
9536
2/2
✓ Branch 0 taken 79964 times.
✓ Branch 1 taken 14072784 times.
14152748 for(int32_t i=0; i<176; ++i)
9537 {
9538
2/2
✓ Branch 0 taken 2177120 times.
✓ Branch 1 taken 62822496 times.
64999616 for(int32_t layer=0; layer<7; ++layer)
9539 {
9540
2/2
✓ Branch 0 taken 48749712 times.
✓ Branch 1 taken 14072784 times.
62822496 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9541 62822496 newcombo const& cmb = combobuf[cid];
9542
9543
2/2
✓ Branch 0 taken 15239840 times.
✓ Branch 1 taken 47582656 times.
62822496 if(!get_bit(quest_rules,qr_AUTOCOMBO_ANY_LAYER))
9544 {
9545
2/2
✓ Branch 0 taken 11895664 times.
✓ Branch 1 taken 35686992 times.
47582656 if(layer > 2) break;
9546
4/4
✓ Branch 0 taken 11895664 times.
✓ Branch 1 taken 23791328 times.
✓ Branch 2 taken 11687456 times.
✓ Branch 3 taken 208208 times.
35686992 if (layer == 1 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_1)) continue;
9547
4/4
✓ Branch 0 taken 11895664 times.
✓ Branch 1 taken 12103872 times.
✓ Branch 2 taken 208208 times.
✓ Branch 3 taken 11687456 times.
23999536 if (layer == 2 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_2)) continue;
9548 12312080 }
9549 27551920 int32_t ind=0;
9550
9551 //AUTOMATIC TRIGGER CODE
9552
1/2
✓ Branch 0 taken 27551920 times.
✗ Branch 1 not taken.
27551920 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9553 {
9554 do_trigger_combo(layer, i);
9555 }
9556
9557 //AUTO WARP CODE
9558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27551920 times.
27551920 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9559 {
9560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27551920 times.
27551920 if(cmb.type==cAWARPA)
9561 {
9562 awarp=true;
9563 ind=0;
9564 }
9565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27551920 times.
27551920 else if(cmb.type==cAWARPB)
9566 {
9567 awarp=true;
9568 ind=1;
9569 }
9570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27551920 times.
27551920 else if(cmb.type==cAWARPC)
9571 {
9572 awarp=true;
9573 ind=2;
9574 }
9575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27551920 times.
27551920 else if(cmb.type==cAWARPD)
9576 {
9577 awarp=true;
9578 ind=3;
9579 }
9580
1/2
✓ Branch 0 taken 27551920 times.
✗ Branch 1 not taken.
27551920 else if(cmb.type==cAWARPR)
9581 {
9582 awarp=true;
9583 ind=zc_oldrand()%4;
9584 }
9585 27551920 }
9586
1/2
✓ Branch 0 taken 27551920 times.
✗ Branch 1 not taken.
27551920 if(awarp)
9587 {
9588 if(tmpscr->flags5&fDIRECTAWARP)
9589 {
9590 didpit=true;
9591 pitx=x;
9592 pity=y;
9593 }
9594
9595 sdir = dir;
9596 dowarp(1,ind);
9597 break;
9598 }
9599 27551920 }
9600
1/2
✓ Branch 0 taken 14072784 times.
✗ Branch 1 not taken.
14072784 if(awarp) break;
9601 14072784 }
9602
9603 79964 awarp=false;
9604
9605 79964 word c = tmpscr->numFFC();
9606
2/2
✓ Branch 0 taken 79964 times.
✓ Branch 1 taken 2350404 times.
2430368 for(word i=0; i<c; i++)
9607 {
9608 2350404 int32_t ind=0;
9609
9610 2350404 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9611
9612
1/2
✓ Branch 0 taken 2350404 times.
✗ Branch 1 not taken.
2350404 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9613 {
9614 do_trigger_combo_ffc(i);
9615 }
9616
9617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2350404 times.
2350404 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9618 {
9619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2350404 times.
2350404 if(cmb.type==cAWARPA)
9620 {
9621 awarp=true;
9622 ind=0;
9623 }
9624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2350404 times.
2350404 else if(cmb.type==cAWARPB)
9625 {
9626 awarp=true;
9627 ind=1;
9628 }
9629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2350404 times.
2350404 else if(cmb.type==cAWARPC)
9630 {
9631 awarp=true;
9632 ind=2;
9633 }
9634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2350404 times.
2350404 else if(cmb.type==cAWARPD)
9635 {
9636 awarp=true;
9637 ind=3;
9638 }
9639
1/2
✓ Branch 0 taken 2350404 times.
✗ Branch 1 not taken.
2350404 else if(cmb.type==cAWARPR)
9640 {
9641 awarp=true;
9642 ind=zc_oldrand()%4;
9643 }
9644 2350404 }
9645
9646
1/2
✓ Branch 0 taken 2350404 times.
✗ Branch 1 not taken.
2350404 if(awarp)
9647 {
9648 if(tmpscr->flags5&fDIRECTAWARP)
9649 {
9650 didpit=true;
9651 pitx=x;
9652 pity=y;
9653 }
9654
9655 sdir = dir;
9656 dowarp(1,ind);
9657 break;
9658 }
9659 2350404 }
9660 79964 zfix dx, dy;
9661
7/8
✓ Branch 0 taken 6946 times.
✓ Branch 1 taken 73018 times.
✓ Branch 2 taken 4508 times.
✓ Branch 3 taken 2438 times.
✓ Branch 4 taken 2082 times.
✓ Branch 5 taken 2426 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2082 times.
79964 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9662 {
9663
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2045 times.
2082 if (slide_slope(this, dx, dy, slopeid))
9664 {
9665 2045 onplatid = 5;
9666
3/4
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 1265 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 780 times.
2045 if (dx || dy) push_move(dx, dy);
9667 2045 }
9668 2082 }
9669
2/2
✓ Branch 0 taken 77317 times.
✓ Branch 1 taken 2647 times.
79964 if (onplatid <= 0) slopeid = 0;
9670 2647 else --onplatid;
9671
2/2
✓ Branch 0 taken 63956 times.
✓ Branch 1 taken 16008 times.
79964 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9672
5/6
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 79948 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 968 times.
✓ Branch 5 taken 79964 times.
80932 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9673 {
9674
2/4
✓ Branch 0 taken 968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 968 times.
968 if (check_slope(this, true) && !toogam)
9675 {
9676 968 slope_info const& s = get_slope(this, true).get_info();
9677 968 bool staircheck = false;
9678
4/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 63 times.
968 if (s.slope() != slopeid && slopeid) staircheck = true;
9679
2/2
✓ Branch 0 taken 931 times.
✓ Branch 1 taken 37 times.
968 if (onplatform) staircheck = true;
9680 968 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9681
9682
4/4
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 734 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 28 times.
968 if (dx || dy)
9683 {
9684 940 int32_t pushret = push_move(dx,dy);
9685
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 20 times.
940 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9686
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 830 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 59 times.
940 if (s.slope() != slopeid && slopeid) staircheck = true;
9687
2/2
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 18 times.
940 if (onplatform) staircheck = true;
9688
4/4
✓ Branch 0 taken 908 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 882 times.
940 if(sideview_mode() && slopeid)
9689 882 onplatid = 5;
9690
1/2
✓ Branch 0 taken 940 times.
✗ Branch 1 not taken.
940 if (pushret == 1)
9691 {
9692 dx = -1;
9693 dy = 0;
9694 slope_push_int(s, this, dx, dy, staircheck);
9695 push_move(dx,dy);
9696 }
9697
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 12 times.
940 if (pushret == 2)
9698 {
9699 12 dx = 0;
9700 12 dy = -1;
9701 12 slope_push_int(s, this, dx, dy, staircheck);
9702 12 push_move(dx,dy);
9703 12 }
9704 940 }
9705 968 }
9706 968 }
9707
9708
2/2
✓ Branch 0 taken 79962 times.
✓ Branch 1 taken 2 times.
79964 if(ffwarp)
9709 {
9710
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(ffpit)
9711 {
9712 ffpit=false;
9713 didpit=true;
9714 pitx=x;
9715 pity=y;
9716 }
9717
9718 2 ffwarp=false;
9719 2 dowarp(1,0);
9720 2 }
9721
9722 //Hero->WarpEx
9723
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if ( FFCore.warpex[wexActive] )
9724 {
9725 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9726 FFCore.warpex[wexActive] = 0;
9727 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9728 for ( int32_t q = 0; q < wexActive; q++ )
9729 {
9730 temp_warpex[q] = FFCore.warpex[q];
9731 FFCore.warpex[q] = 0;
9732 }
9733 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9734 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9735 }
9736
9737 // walk through bombed doors and fake walls
9738 79964 bool walk=false;
9739 79964 int32_t dtype=dBOMBED;
9740
9741
2/2
✓ Branch 0 taken 77895 times.
✓ Branch 1 taken 2069 times.
79964 if(pushing>=24) dtype=dWALK;
9742
9743
13/18
✓ Branch 0 taken 41766 times.
✓ Branch 1 taken 38198 times.
✓ Branch 2 taken 41338 times.
✓ Branch 3 taken 428 times.
✓ Branch 4 taken 41338 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41266 times.
✓ Branch 7 taken 72 times.
✓ Branch 8 taken 41266 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 41266 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 41266 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 41266 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 444 times.
✓ Branch 17 taken 41710 times.
79964 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9744 {
9745
11/16
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 40746 times.
✓ Branch 2 taken 7822 times.
✓ Branch 3 taken 32924 times.
✓ Branch 4 taken 7822 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7822 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1501 times.
✓ Branch 11 taken 6321 times.
✓ Branch 12 taken 542 times.
✓ Branch 13 taken 959 times.
✓ Branch 14 taken 542 times.
✗ Branch 15 not taken.
41710 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y<=32 && tmpscr->door[0]==dtype)
9746 {
9747 walk=true;
9748 dir=up;
9749 }
9750
9751
11/16
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 40746 times.
✓ Branch 2 taken 3935 times.
✓ Branch 3 taken 36811 times.
✓ Branch 4 taken 4899 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4899 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 631 times.
✓ Branch 11 taken 4268 times.
✓ Branch 12 taken 153 times.
✓ Branch 13 taken 478 times.
✓ Branch 14 taken 153 times.
✗ Branch 15 not taken.
41710 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y>=128 && tmpscr->door[1]==dtype)
9752 {
9753 walk=true;
9754 dir=down;
9755 }
9756
9757
9/14
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 40746 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 40524 times.
✓ Branch 4 taken 742 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 742 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 424 times.
✓ Branch 11 taken 318 times.
✓ Branch 12 taken 424 times.
✗ Branch 13 not taken.
41710 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[2]==dtype)
9758 {
9759 walk=true;
9760 dir=left;
9761 }
9762
9763
9/14
✓ Branch 0 taken 40302 times.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 39609 times.
✓ Branch 4 taken 1657 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1657 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 673 times.
✓ Branch 11 taken 984 times.
✓ Branch 12 taken 673 times.
✗ Branch 13 not taken.
41266 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[3]==dtype)
9764 {
9765 walk=true;
9766 dir=right;
9767 }
9768 41266 }
9769
9770
1/2
✓ Branch 0 taken 80408 times.
✗ Branch 1 not taken.
80408 if(walk)
9771 {
9772 hclk=0;
9773 drawguys=false;
9774
9775 if(dtype==dWALK)
9776 {
9777 sfx(tmpscr->secretsfx);
9778 }
9779
9780 action=none; FFCore.setHeroAction(none);
9781 stepforward(29, true);
9782 action=scrolling; FFCore.setHeroAction(scrolling);
9783 pushing=false;
9784 }
9785
9786
4/6
✓ Branch 0 taken 8135 times.
✓ Branch 1 taken 72273 times.
✓ Branch 2 taken 8135 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8135 times.
80408 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9787 {
9788
1/2
✓ Branch 0 taken 8135 times.
✗ Branch 1 not taken.
8135 if(heart_beep)
9789 {
9790 8135 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9791 8135 }
9792 else
9793 {
9794 if ( heart_beep_timer == -1 )
9795 {
9796 heart_beep_timer = 70;
9797 }
9798
9799 if ( heart_beep_timer > 0 )
9800 {
9801 --heart_beep_timer;
9802 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9803 }
9804 else
9805 {
9806 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9807 }
9808 }
9809 8135 }
9810 else
9811 {
9812
2/2
✓ Branch 0 taken 449 times.
✓ Branch 1 taken 71824 times.
72273 if ( heart_beep_timer > -2 )
9813 {
9814 71824 heart_beep_timer = -1;
9815 71824 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9816 71824 }
9817 }
9818
9819
2/2
✓ Branch 0 taken 80405 times.
✓ Branch 1 taken 3 times.
80408 if(rSbtn())
9820 {
9821 3 int32_t tmp_subscr_clk = frame;
9822
9823 3 int32_t save_type = 0;
9824
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 switch(lsave)
9825 {
9826 case 0:
9827 {
9828
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if( FFCore.runActiveSubscreenScriptEngine() )
9829 {
9830 1 break;
9831 }
9832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 else if ( !stopSubscreenFalling() )
9833 {
9834 2 conveyclk=3;
9835 2 dosubscr(&QMisc);
9836 2 newscr_clk += frame - tmp_subscr_clk;
9837 2 }
9838 2 break;
9839 }
9840
9841
9842 case 2:
9843 save_type = 1;
9844 [[fallthrough]];
9845 case 1:
9846 if(last_savepoint_id)
9847 trigger_save(combobuf[last_savepoint_id]);
9848 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9849 break;
9850 }
9851 3 }
9852
9853
2/2
✓ Branch 0 taken 3946 times.
✓ Branch 1 taken 76462 times.
80408 if (!checkstab() )
9854 {
9855 /*
9856 for(int32_t q=0; q<176; q++)
9857 {
9858 set_bit(screengrid,q,0);
9859 }
9860
9861 for(int32_t q=0; q<MAXFFCS; q++)
9862 set_bit(ffcgrid, q, 0);
9863 */
9864 76462 }
9865
9866 80408 check_conveyor();
9867 80408 PhantomsCleanup();
9868 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9869
1/2
✓ Branch 0 taken 80408 times.
✗ Branch 1 not taken.
80408 if(attack==wHammer)
9870 {
9871 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9872 {
9873 switch(dir) //Hero's dir
9874 {
9875 case up:
9876 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
9877 break;
9878
9879 case down:
9880 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
9881 break;
9882
9883 case left:
9884 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
9885 break;
9886
9887 case right:
9888 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
9889 break;
9890 }
9891
9892 }
9893 }
9894
9895 80408 handleSpotlights();
9896
9897
2/2
✓ Branch 0 taken 80189 times.
✓ Branch 1 taken 219 times.
80408 if(getOnSideviewLadder())
9898 {
9899
5/8
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 214 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 214 times.
219 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
9900 {
9901 5 setOnSideviewLadder(false);
9902 5 }
9903
4/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 174 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 40 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
214 else if(CANFORCEFACEUP)
9904 {
9905 40 setDir(up);
9906 40 }
9907 219 }
9908
9909 80408 return false;
9910 80408 }
9911
9912 6470 bool HeroClass::push_pixel(zfix dx, zfix dy)
9913 {
9914
2/4
✓ Branch 0 taken 6470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6470 times.
✗ Branch 3 not taken.
6470 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
9915
3/4
✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 3014 times.
✓ Branch 2 taken 3456 times.
✗ Branch 3 not taken.
6470 if(dx && dy)
9916 {
9917 bool r = push_pixel(0,dy);
9918 bool r2 = push_pixel(dx,0);
9919 return r && r2;
9920 }
9921
2/2
✓ Branch 0 taken 3091 times.
✓ Branch 1 taken 3379 times.
6470 if(dx < 0)
9922 {
9923
1/2
✓ Branch 0 taken 3091 times.
✗ Branch 1 not taken.
6182 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
9924
1/2
✓ Branch 0 taken 3091 times.
✗ Branch 1 not taken.
3091 || solpush_walkflag(x+dx,y+8,1,this)
9925
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3091 times.
✓ Branch 2 taken 2680 times.
✓ Branch 3 taken 411 times.
3091 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
9926 {
9927 3091 x += dx;
9928 3091 return true;
9929 }
9930 return false;
9931 }
9932
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 3014 times.
3379 else if(dx > 0)
9933 {
9934
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
730 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
9935
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 || solpush_walkflag(x+15+dx,y+8,1,this)
9936
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
✓ Branch 2 taken 218 times.
✓ Branch 3 taken 147 times.
365 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
9937 {
9938 365 x += dx;
9939 365 return true;
9940 }
9941 return false;
9942 }
9943
2/2
✓ Branch 0 taken 1757 times.
✓ Branch 1 taken 1257 times.
3014 else if(dy < 0)
9944 {
9945
1/2
✓ Branch 0 taken 1757 times.
✗ Branch 1 not taken.
3514 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
9946
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1757 times.
✓ Branch 2 taken 1623 times.
✓ Branch 3 taken 134 times.
1757 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
9947 {
9948 1757 y += dy;
9949 1757 return true;
9950 }
9951 return false;
9952 }
9953
1/2
✓ Branch 0 taken 1257 times.
✗ Branch 1 not taken.
1257 else if(dy > 0)
9954 {
9955
2/2
✓ Branch 0 taken 1220 times.
✓ Branch 1 taken 37 times.
2494 if(!(solpush_walkflag(x,y+15+dy,2,this)
9956
4/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1237 times.
✓ Branch 2 taken 224 times.
✓ Branch 3 taken 1013 times.
1257 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
9957 {
9958 1220 y += dy;
9959 1220 return true;
9960 }
9961 37 return false;
9962 }
9963 return false;
9964 6470 }
9965 3407 int32_t HeroClass::push_move(zfix dx, zfix dy)
9966 {
9967 3407 int32_t ret = 0;
9968
4/4
✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 4259 times.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 4308 times.
7715 while(dx || dy)
9969 {
9970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4308 times.
4308 if(check_pitslide() != -1)
9971 break;
9972
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 3014 times.
4308 if(dy)
9973 {
9974
2/2
✓ Branch 0 taken 2128 times.
✓ Branch 1 taken 886 times.
3014 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
9975 3014 dy -= cy;
9976
2/2
✓ Branch 0 taken 2977 times.
✓ Branch 1 taken 37 times.
3014 if(!push_pixel(0,cy))
9977 {
9978 37 dy = 0;
9979 37 ret |= 2;
9980 37 }
9981 3014 }
9982
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 3456 times.
4308 if(dx)
9983 {
9984
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 2012 times.
3456 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
9985 3456 dx -= cx;
9986
1/2
✓ Branch 0 taken 3456 times.
✗ Branch 1 not taken.
3456 if(!push_pixel(cx,0))
9987 {
9988 dx = 0;
9989 ret |= 1;
9990 }
9991 3456 }
9992 }
9993 3407 return ret;
9994 }
9995
9996 79959 bool HeroClass::setSolid(bool set)
9997 {
9998
1/2
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
79959 bool actual = set && !toogam; //not solid when noclipping
9999 79959 bool ret = solid_object::setSolid(actual);
10000 79959 solid = set;
10001 79959 return ret;
10002 }
10003
10004 10647 void HeroClass::solid_push(solid_object* obj)
10005 {
10006
1/2
✓ Branch 0 taken 10647 times.
✗ Branch 1 not taken.
10647 if(obj == this) return; //can't push self
10007
10008 10647 zfix dx, dy;
10009 10647 int32_t hdir = -1;
10010 10647 solid_push_int(obj,dx,dy,hdir);
10011
10012
4/4
✓ Branch 0 taken 9722 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 9457 times.
✓ Branch 3 taken 265 times.
10647 if(!dx && !dy) return;
10013
10014 1190 obj->doContactDamage(hdir);
10015
10016 1190 bool t = obj->getTempNonsolid();
10017 1190 obj->setTempNonsolid(true);
10018
10019 1190 push_move(dx,dy);
10020
10021 1190 obj->setTempNonsolid(t);
10022 10647 }
10023
10024 // A routine used exclusively by startwpn,
10025 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10026 5 void HeroClass::deselectbombs(int32_t super)
10027 {
10028
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
5 if ( get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10029 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10030 {
10031 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10032 Bwpn = Bweapon(temp);
10033 directItemB = directItem;
10034 game->bwpn = temp;
10035 }
10036
10037 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10038 {
10039 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10040 Xwpn = Bweapon(temp);
10041 directItemX = directItem;
10042 game->xwpn = temp;
10043 }
10044 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10045 {
10046 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
10047 Ywpn = Bweapon(temp);
10048 directItemY = directItem;
10049 game->ywpn = temp;
10050 }
10051 else
10052 {
10053 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10054 Awpn = Bweapon(temp);
10055 directItemA = directItem;
10056 game->awpn = temp;
10057 }
10058 5 }
10059
10060 int32_t potion_life=0;
10061 int32_t potion_magic=0;
10062
10063 bool HeroClass::mirrorBonk()
10064 {
10065 zfix tx = x, ty = y, tz = z;
10066 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10067 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10068 execute(info);
10069 bool fail = info.isUnwalkable();
10070
10071 if(!fail) //not solid, but check for water/pits...
10072 {
10073 //{ Check water collision.... GAAAAAAAH THIS IS A MESS
10074 int32_t water = 0;
10075 int32_t types[4] = {0};
10076 int32_t x1 = x+4, x2 = x+11,
10077 y1 = y+9, y2 = y+15;
10078 if (get_bit(quest_rules, qr_SMARTER_WATER))
10079 {
10080 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10081 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10082 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10083 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10084 }
10085 else
10086 {
10087 types[0] = COMBOTYPE(x1,y1);
10088
10089 if(MAPFFCOMBO(x1,y1))
10090 types[0] = FFCOMBOTYPE(x1,y1);
10091
10092 types[1] = COMBOTYPE(x1,y2);
10093
10094 if(MAPFFCOMBO(x1,y2))
10095 types[1] = FFCOMBOTYPE(x1,y2);
10096
10097 types[2] = COMBOTYPE(x2,y1);
10098
10099 if(MAPFFCOMBO(x2,y1))
10100 types[2] = FFCOMBOTYPE(x2,y1);
10101
10102 types[3] = COMBOTYPE(x2,y2);
10103
10104 if(MAPFFCOMBO(x2,y2))
10105 types[3] = FFCOMBOTYPE(x2,y2);
10106
10107 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10108 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10109 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10110
10111 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10112 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10113 water = typec;
10114 }
10115 if(water > 0)
10116 {
10117 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10118 {
10119 fail = true;
10120 }
10121 }
10122 //}
10123 if(pitslide() || fallclk)
10124 fail = true;
10125 fallclk = 0;
10126 }
10127 x = tx; y = ty; z = tz;
10128 return fail;
10129 }
10130
10131 void HeroClass::doMirror(int32_t mirrorid)
10132 {
10133 if(z > 0 || fakez > 0) return; //No mirror in air
10134 if(mirrorid < 0)
10135 mirrorid = current_item_id(itype_mirror);
10136 if(mirrorid < 0) return;
10137
10138 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10139 {
10140 if(QMisc.miscsfx[sfxERROR])
10141 sfx(QMisc.miscsfx[sfxERROR]);
10142 return;
10143 }
10144 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10145 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10146 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10147 for(auto pos : posarr)
10148 {
10149 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10150 {
10151 if(QMisc.miscsfx[sfxERROR])
10152 sfx(QMisc.miscsfx[sfxERROR]);
10153 return;
10154 }
10155 }
10156
10157 itemdata const& mirror = itemsbuf[mirrorid];
10158 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10159 {
10160 paymagiccost(mirrorid);
10161 if(mirror.usesound2) sfx(mirror.usesound2);
10162
10163 doWarpEffect(mirror.misc2, true);
10164 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10165 {
10166 Quit = qCONT;
10167 skipcont = 1;
10168 }
10169 else //Act as Farore's Wind
10170 {
10171 int32_t nayrutemp=nayruitem;
10172 restart_level();
10173 nayruitem=nayrutemp;
10174 magicitem=-1;
10175 magiccastclk=0;
10176 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10177 }
10178 }
10179 else
10180 {
10181 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10182 int32_t offscr = currscr - DMaps[currdmap].xoff;
10183 if(destdmap < 0)
10184 return;
10185 int32_t destscr = DMaps[destdmap].xoff + offscr;
10186 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10187 return;
10188 paymagiccost(mirrorid);
10189
10190 //Store some values to restore if 'warp fails'
10191 int32_t tLastEntrance = lastentrance,
10192 tLastEntranceDMap = lastentrance_dmap,
10193 tContScr = game->get_continue_scrn(),
10194 tContDMap = game->get_continue_dmap(),
10195 tPortalDMap = game->portalsrcdmap;
10196 int32_t sourcescr = currscr, sourcedmap = currdmap;
10197 zfix tx = x, ty = y, tz = z;
10198 game->portalsrcdmap = -1;
10199 action = none; FFCore.setHeroAction(none);
10200
10201 //Warp to new dmap
10202 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10203 mirror.usesound, 0, -1);
10204
10205 //Check for valid landing location
10206 if(mirrorBonk()) //Invalid landing, warp back!
10207 {
10208 action = none; FFCore.setHeroAction(none);
10209 lastentrance = tLastEntrance;
10210 lastentrance_dmap = tLastEntranceDMap;
10211 game->set_continue_scrn(tContScr);
10212 game->set_continue_dmap(tContDMap);
10213 x = tx;
10214 y = ty;
10215 z = tz;
10216 game->portalsrcdmap = tPortalDMap;
10217 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10218 mirror.usesound, 0, -1);
10219 }
10220 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10221 {
10222 //Place the portal
10223 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10224 //Since it was placed after loading this screen, load the portal object now
10225 game->load_portal();
10226 //Don't immediately trigger the warp back
10227 can_mirror_portal = false;
10228
10229 //Set continue point
10230 if(currdmap != game->get_continue_dmap())
10231 {
10232 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10233 }
10234 game->set_continue_dmap(currdmap);
10235 lastentrance_dmap = currdmap;
10236 lastentrance = game->get_continue_scrn();
10237 }
10238 }
10239 }
10240
10241 79964 void HeroClass::handle_passive_buttons()
10242 {
10243 79964 do_liftglove(-1,true);
10244 79964 do_jump(-1,true);
10245 79964 }
10246
10247 static bool did_passive_jump = false;
10248 80023 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10249 {
10250
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 79964 times.
80023 if(passive) did_passive_jump = false;
10251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 else if(did_passive_jump) return false; //don't jump twice in the same frame
10252
10253
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 79964 times.
80023 if(jumpid < 0)
10254 79964 jumpid = current_item_id(itype_rocs,true,true);
10255
10256
2/2
✓ Branch 0 taken 67594 times.
✓ Branch 1 taken 12429 times.
80023 if(unsigned(jumpid) >= MAXITEMS) return false;
10257
2/4
✓ Branch 0 taken 12429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12429 times.
12429 if(inlikelike || charging) return false;
10258
1/2
✓ Branch 0 taken 12429 times.
✗ Branch 1 not taken.
12429 if(!checkitem_jinx(jumpid)) return false;
10259
10260 12429 itemdata const& itm = itemsbuf[jumpid];
10261
10262 12429 bool standing = isStanding(true);
10263
3/4
✓ Branch 0 taken 10388 times.
✓ Branch 1 taken 2041 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2041 times.
12429 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10264
4/6
✓ Branch 0 taken 12429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2041 times.
✓ Branch 3 taken 10388 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2041 times.
12429 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10265
2/4
✓ Branch 0 taken 10388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10388 times.
10388 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10266 {
10267 if(QMisc.miscsfx[sfxERROR])
10268 sfx(QMisc.miscsfx[sfxERROR]);
10269 return false;
10270 }
10271
10272 10388 byte intbtn = byte(itm.misc2&0xFF);
10273
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 10334 times.
10388 if(passive)
10274 {
10275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10334 times.
10334 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10276 10334 return false; //not pressed
10277 }
10278
10279 54 paymagiccost(jumpid);
10280
10281
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!standing)
10282 {
10283 ++extra_jump_count;
10284 fall = 0;
10285 fakefall = 0;
10286 if(hoverclk > 0)
10287 hoverclk = -hoverclk;
10288 }
10289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(itm.flags & ITEM_FLAG1)
10290 setFall(fall - itm.power);
10291 54 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10292 54 coyotetime = 65535; //jumped, so no coyotetime
10293 54 setOnSideviewLadder(false);
10294
10295 // Reset the ladder, unless on an unwalkable combo
10296
3/10
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
54 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10297 reset_ladder();
10298
10299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(itm.usesound)
10300 54 sfx(itm.usesound,pan(x.getInt()));
10301
10302
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(passive) did_passive_jump = true;
10303 54 return true;
10304 80023 }
10305 130 void HeroClass::drop_liftwpn()
10306 {
10307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!lift_wpn) return;
10308
10309 handle_lift(false); //sets position properly, accounting for large weapons
10310 auto liftid = current_item_id(itype_liftglove,true,true);
10311 itemdata const& glove = itemsbuf[liftid];
10312 if(glove.flags & ITEM_FLAG1)
10313 {
10314 lift_wpn->z = 0;
10315 lift_wpn->fakez = liftheight;
10316 }
10317 else lift_wpn->z = liftheight;
10318 lift_wpn->dir = dir;
10319 lift_wpn->step = 0;
10320 lift_wpn->fakefall = 0;
10321 lift_wpn->fall = 0;
10322 if(glove.flags & ITEM_FLAG1)
10323 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10324 else
10325 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10326 Lwpns.add(lift_wpn);
10327 lift_wpn = nullptr;
10328 130 }
10329 79964 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10330 {
10331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79964 times.
79964 if(liftid < 0)
10332 79964 liftid = current_item_id(itype_liftglove,true,true);
10333
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 79345 times.
79964 if(!can_lift(liftid)) return;
10334 619 itemdata const& glove = itemsbuf[liftid];
10335 619 byte intbtn = byte(glove.misc1&0xFF);
10336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(passive)
10337 {
10338
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 610 times.
619 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10339 610 return; //not pressed
10340 9 }
10341
10342 9 bool had_weapon = lift_wpn;
10343
10344
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10345
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (checkbunny(liftid) && checkmagiccost(liftid))))
10346 {
10347 if(QMisc.miscsfx[sfxERROR])
10348 sfx(QMisc.miscsfx[sfxERROR]);
10349 return;
10350 }
10351
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if(glove.script!=0 && (item_doscript[liftid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10352 return;
10353
10354 9 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10355
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(glove.script)
10356 {
10357 if(!paidmagic)
10358 {
10359 paidmagic = true;
10360 paymagiccost(liftid);
10361 }
10362
10363 ri = &(itemScriptData[liftid]);
10364 for ( int32_t q = 0; q < 1024; q++ )
10365 item_stack[liftid][q] = 0xFFFF;
10366 ri->Clear();
10367 item_doscript[liftid] = 1;
10368 itemscriptInitialised[liftid] = 0;
10369 ZScriptVersion::RunScript(SCRIPT_ITEM, glove.script, liftid);
10370
10371 bool has_weapon = lift_wpn;
10372 if(has_weapon != had_weapon) //Item action script changed the lift information
10373 {
10374 if(passive)
10375 {
10376 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10377 }
10378 return;
10379 }
10380 }
10381
10382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(lift_wpn)
10383 {
10384 if(!paidmagic)
10385 {
10386 paidmagic = true;
10387 paymagiccost(liftid);
10388 }
10389 if(!liftclk)
10390 {
10391 //Throw the weapon!
10392 //hero's direction and position
10393 handle_lift(false); //sets position properly, accounting for large weapons
10394 if(glove.flags & ITEM_FLAG1)
10395 {
10396 lift_wpn->z = 0;
10397 lift_wpn->fakez = liftheight;
10398 }
10399 else lift_wpn->z = liftheight;
10400 lift_wpn->dir = dir;
10401 //Configured throw speed in both axes
10402 lift_wpn->step = zfix(glove.misc2)/100;
10403 if(glove.flags & ITEM_FLAG1)
10404 {
10405 lift_wpn->fakefall = -glove.misc3;
10406 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10407 }
10408 else
10409 {
10410 lift_wpn->fall = -glove.misc3;
10411 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10412 }
10413 Lwpns.add(lift_wpn);
10414 lift_wpn = nullptr;
10415 if(glove.usesound2)
10416 sfx(glove.usesound2,pan(int32_t(x)));
10417 }
10418
10419 if(passive)
10420 {
10421 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10422 }
10423 return;
10424 }
10425
10426 //Check for a liftable combo
10427 9 zfix bx, by;
10428 9 zfix bx2, by2;
10429
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
9 switch(dir)
10430 {
10431 case up:
10432 9 by = y + (bigHitbox ? -2 : 6);
10433 9 by2 = by;
10434 9 bx = x + 4;
10435 9 bx2 = bx + 8;
10436 9 break;
10437 case down:
10438 by = y + 17;
10439 by2 = by;
10440 bx = x + 4;
10441 bx2 = bx + 8;
10442 break;
10443 case left:
10444 by = y + (bigHitbox ? 0 : 8);
10445 by2 = y + 8;
10446 bx = x - 2;
10447 bx2 = x - 2;
10448 break;
10449 case right:
10450 by = y + (bigHitbox ? 0 : 8);
10451 by2 = y + 8;
10452 bx = x + 17;
10453 bx2 = x + 17;
10454 break;
10455 }
10456 9 int32_t pos = COMBOPOS_B(bx,by);
10457 9 int32_t pos2 = COMBOPOS_B(bx2,by2);
10458 9 int32_t foundpos = -1;
10459
10460 9 bool lifted = false;
10461
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
72 for(auto lyr = 6; lyr >= 0; --lyr)
10462 {
10463 63 mapscr* scr = FFCore.tempScreens[lyr];
10464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(pos > -1)
10465 {
10466 63 newcombo const& cmb = combobuf[scr->data[pos]];
10467
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(cmb.liftflags & LF_LIFTABLE)
10468 {
10469 if(do_lift_combo(lyr,pos,liftid))
10470 {
10471 lifted = true;
10472 break;
10473 }
10474 }
10475 63 }
10476
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(pos != pos2 && pos2 > -1)
10477 {
10478 63 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10479
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(cmb2.liftflags & LF_LIFTABLE)
10480 {
10481 if(do_lift_combo(lyr,pos2,liftid))
10482 {
10483 lifted = true;
10484 break;
10485 }
10486 }
10487 63 }
10488 63 }
10489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!lifted) return;
10490 if(!paidmagic)
10491 {
10492 paidmagic = true;
10493 paymagiccost(liftid);
10494 }
10495 if(passive)
10496 {
10497 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10498 }
10499 return;
10500 79964 }
10501 void HeroClass::handle_lift(bool dec)
10502 {
10503 lift_wpn->fakez = 0;
10504 if(!lift_wpn) liftclk = 0;
10505 if(liftclk <= (dec?1:0))
10506 {
10507 liftclk = 0;
10508 tliftclk = 0;
10509 if(lift_wpn)
10510 {
10511 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10512 {
10513 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10514 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10515 }
10516 else
10517 {
10518 lift_wpn->x = x;
10519 lift_wpn->y = y;
10520 }
10521 lift_wpn->z = liftheight;
10522 }
10523 if(action == lifting)
10524 {
10525 action = none; FFCore.setHeroAction(none);
10526 }
10527 return;
10528 }
10529 if(dec) --liftclk;
10530 double xdist, ydist;
10531 double perc = (liftclk/double(tliftclk));
10532 switch(dir)
10533 {
10534 case up:
10535 {
10536 xdist = 0;
10537 ydist = -16;
10538 if(lift_wpn->txsz > 1)
10539 {
10540 xdist = -((lift_wpn->txsz*8)-8);
10541 }
10542 else xdist = 0;
10543 if(lift_wpn->tysz > 1)
10544 {
10545 ydist = -(lift_wpn->tysz*16);
10546 }
10547 ydist *= perc;
10548 break;
10549 }
10550 case down:
10551 {
10552 xdist = 0;
10553 ydist = 16;
10554 if(lift_wpn->txsz > 1)
10555 {
10556 xdist = -((lift_wpn->txsz*8)-8);
10557 }
10558 else xdist = 0;
10559 ydist *= perc;
10560 break;
10561 }
10562 case left:
10563 {
10564 xdist = -16;
10565 ydist = 0;
10566 if(lift_wpn->txsz > 1)
10567 {
10568 xdist = -(lift_wpn->txsz*16);
10569 }
10570 if(lift_wpn->tysz > 1)
10571 {
10572 ydist = -((lift_wpn->tysz*8)-8);
10573 }
10574 else ydist = 0;
10575 xdist *= perc;
10576 break;
10577 }
10578 case right:
10579 {
10580 xdist = 16;
10581 ydist = 0;
10582 if(lift_wpn->tysz > 1)
10583 {
10584 ydist = -((lift_wpn->tysz*8)-8);
10585 }
10586 else ydist = 0;
10587 xdist *= perc;
10588 break;
10589 }
10590 }
10591
10592 lift_wpn->x = x + xdist;
10593 lift_wpn->y = y + ydist;
10594 lift_wpn->z = liftheight*(1.0-perc);
10595 }
10596 79964 bool HeroClass::can_lift(int32_t gloveid)
10597 {
10598
2/2
✓ Branch 0 taken 79345 times.
✓ Branch 1 taken 619 times.
79964 if(unsigned(gloveid) >= MAXITEMS) return false;
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(lstunclock) return false;
10600
1/2
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
619 if(!checkitem_jinx(gloveid)) return false;
10601 619 itemdata const& glove = itemsbuf[gloveid];
10602
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
✗ Branch 2 not taken.
619 switch(action)
10603 {
10604 case none: case walking:
10605 619 break;
10606
10607 case swimming:
10608 if(glove.flags & ITEM_FLAG2)
10609 break;
10610 return false;
10611
10612 default:
10613 return false;
10614 }
10615 619 return true;
10616 79964 }
10617 void HeroClass::lift(weapon* w, byte timer, zfix height)
10618 {
10619 lift_wpn = w;
10620 liftclk = timer;
10621 tliftclk = timer;
10622 if(height < 0)
10623 liftheight = 0;
10624 else liftheight = height;
10625 }
10626
10627 void HeroClass::doSwitchHook(byte style)
10628 {
10629 hs_switcher = true;
10630 pull_hero = true;
10631 //{ Load hook weapons, set them to obey special drawing
10632 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10633 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10634
10635 if(w)
10636 w->switch_hooked = true;
10637 if(hw)
10638 hw->switch_hooked = true;
10639 for(int32_t j=0; j<chainlinks.Count(); j++)
10640 {
10641 chainlinks.spr(j)->switch_hooked = true;
10642 }
10643 //}
10644 if(hooked_combopos > -1)
10645 {
10646 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10647 hooked_layerbits = 0;
10648 for(auto q = 0; q < 7; ++q)
10649 hooked_undercombos[q] = -1;
10650 uint16_t plpos = COMBOPOS(x+8,y+8);
10651 for(auto q = max_layer; q > -1; --q)
10652 {
10653 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10654 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10655 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10656 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10657 bool isPush = false;
10658 if(isSwitchHookable(cmb))
10659 {
10660 if(cmb.type == cSWITCHHOOK)
10661 {
10662 uint16_t plpos = COMBOPOS(x+8,y+8);
10663 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10664 continue; //don't swap with non-zero combo
10665 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10666 continue; //too low a switchhook level
10667 hooked_layerbits |= 1<<q; //Swapping
10668 if(cmb.usrflags&cflag3)
10669 {
10670 if(cmb.usrflags&cflag6)
10671 {
10672 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10673 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10674 }
10675 else
10676 {
10677 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10678 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10679 }
10680 }
10681 else
10682 {
10683 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10684 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10685 isPush = true;
10686 }
10687 }
10688 else if(isCuttableType(cmb.type))
10689 {
10690 if(isCuttableNextType(cmb.type))
10691 {
10692 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10693 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10694 }
10695 else
10696 {
10697 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10698 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10699 }
10700 hooked_layerbits |= 1<<q; //Swapping
10701 }
10702 else
10703 {
10704 hooked_layerbits |= 1<<q; //Swapping
10705 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10706 }
10707 }
10708 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10709 {
10710 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10711 && hasMainGuy())
10712 {
10713 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10714 continue;
10715 }
10716 if(fl1 == mfPUSHED)
10717 {
10718 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10719 continue;
10720 }
10721 if(!isPush) switch(fl1)
10722 {
10723 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10724 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10725 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10726 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10727 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10728 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10729 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10730 isPush = true;
10731 }
10732 if(!isPush) switch(cmb.flag)
10733 {
10734 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10735 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10736 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10737 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10738 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10739 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10740 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10741 isPush = true;
10742 }
10743 if(isPush) //Check for block holes / triggers
10744 {
10745 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10746 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10747 {
10748 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10749 }
10750 else if(!get_bit(quest_rules, qr_BLOCKHOLE_SAME_ONLY))
10751 {
10752 auto maxLayer = get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10753 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10754 {
10755 if(lyr == q) continue;
10756 switch(FFCore.tempScreens[q]->sflag[plpos])
10757 {
10758 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10759 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10760 lyr=7;
10761 break;
10762 }
10763 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10764 {
10765 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10766 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10767 lyr=7;
10768 break;
10769 }
10770 }
10771 }
10772 }
10773 }
10774 }
10775 }
10776 switch_hooked = true;
10777 switchhookstyle = style;
10778 switch(style)
10779 {
10780 default: case swPOOF:
10781 {
10782 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10783 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
10784 decorations.add(new comboSprite(x, y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10785 if(hooked_combopos > -1)
10786 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10787 else if(switching_object)
10788 decorations.add(new comboSprite(switching_object->x, switching_object->y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10789 break;
10790 }
10791 case swFLICKER:
10792 {
10793 switchhookmaxtime = switchhookclk = 64;
10794 break;
10795 }
10796 case swRISE:
10797 {
10798 switchhookmaxtime = switchhookclk = 64;
10799 break;
10800 }
10801 }
10802 }
10803
10804 552 bool HeroClass::startwpn(int32_t itemid)
10805 {
10806
1/2
✓ Branch 0 taken 552 times.
✗ Branch 1 not taken.
552 if(itemid < 0) return false;
10807 552 itemdata const& itm = itemsbuf[itemid];
10808
4/6
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 475 times.
✓ Branch 2 taken 98 times.
✓ Branch 3 taken 377 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
552 if(((dir==up && y<24) || (dir==down && y>128) ||
10809
4/6
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 552 times.
552 (dir==left && x<32) || (dir==right && x>208)) && !(get_bit(quest_rules,qr_ITEMSONEDGES) || inlikelike))
10810 return false;
10811
10812 552 int32_t wx=x;
10813 552 int32_t wy=y-fakez;
10814 552 int32_t wz=z;
10815 552 bool ret = true;
10816
10817
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 98 times.
✓ Branch 3 taken 155 times.
✓ Branch 4 taken 222 times.
552 switch(dir)
10818 {
10819 case up:
10820 77 wy-=16;
10821 77 break;
10822
10823 case down:
10824 98 wy+=16;
10825 98 break;
10826
10827 case left:
10828 155 wx-=16;
10829 155 break;
10830
10831 case right:
10832 222 wx+=16;
10833 222 break;
10834 }
10835
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
552 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
10836
10837
4/27
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 59 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 320 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 168 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
552 switch(itm.family)
10838 {
10839 case itype_liftglove:
10840 {
10841 do_liftglove(itemid,false);
10842 dowpn = -1;
10843 ret = false;
10844 break;
10845 }
10846 case itype_potion:
10847 {
10848 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10849 {
10850 if(QMisc.miscsfx[sfxERROR])
10851 sfx(QMisc.miscsfx[sfxERROR]);
10852 return false;
10853 }
10854
10855 paymagiccost(itemid);
10856
10857 if(itm.misc1 || itm.misc2)
10858 {
10859 refill_what=REFILL_ALL;
10860 refill_why=itemid;
10861 StartRefill(REFILL_ALL);
10862 potion_life = game->get_life();
10863 potion_magic = game->get_magic();
10864
10865 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10866 //music_pause();
10867 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10868 while(refill())
10869 {
10870 do_refill_waitframe();
10871 }
10872
10873 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10874 //music_resume();
10875 ret = false;
10876 }
10877
10878 break;
10879 }
10880 case itype_bottle:
10881 {
10882 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10883 {
10884 if(QMisc.miscsfx[sfxERROR])
10885 sfx(QMisc.miscsfx[sfxERROR]);
10886 return false;
10887 }
10888 if(itm.script!=0 && (item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10889 return false;
10890
10891 size_t bind = game->get_bottle_slot(itm.misc1);
10892 bool paidmagic = false;
10893 if(itm.script)
10894 {
10895 paidmagic = true;
10896 paymagiccost(itemid);
10897
10898 ri = &(itemScriptData[itemid]);
10899 for ( int32_t q = 0; q < 1024; q++ )
10900 item_stack[itemid][q] = 0xFFFF;
10901 ri->Clear();
10902 item_doscript[itemid] = 1;
10903 itemscriptInitialised[itemid] = 0;
10904 ZScriptVersion::RunScript(SCRIPT_ITEM, itm.script, itemid);
10905 bind = game->get_bottle_slot(itm.misc1);
10906 }
10907 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
10908 if(bt)
10909 {
10910 word toFill[3] = { 0 };
10911 for(size_t q = 0; q < 3; ++q)
10912 {
10913 char c = bt->counter[q];
10914 if(c > -1)
10915 {
10916 if(bt->flags & (1<<q))
10917 {
10918 toFill[q] = (bt->amount[q]==100)
10919 ? game->get_maxcounter(c)
10920 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
10921 }
10922 else toFill[q] = bt->amount[q];
10923 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
10924 {
10925 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
10926 }
10927 }
10928 }
10929 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
10930 bool run = max > 0;
10931 if(get_bit(quest_rules, qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
10932 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
10933 else
10934 {
10935 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
10936 run = true;
10937 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
10938 run = true;
10939 }
10940 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
10941 {
10942 if(bt->flags & BTFLAG_CURESWJINX)
10943 {
10944 swordclk = 0;
10945 verifyAWpn();
10946 }
10947 if(bt->flags & BTFLAG_CUREITJINX)
10948 itemclk = 0;
10949 if(!paidmagic)
10950 paymagiccost(itemid);
10951 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10952 sfx(itm.usesound,pan(x.getInt()));
10953 for(size_t q = 0; q < 20; ++q)
10954 do_refill_waitframe();
10955 double inc = max/60.0; //1 second
10956 double xtra[3]{ 0 };
10957 for(size_t q = 0; q < 60; ++q)
10958 {
10959 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
10960 sfx(QMisc.miscsfx[sfxREFILL]);
10961 for(size_t j = 0; j < 3; ++j)
10962 {
10963 xtra[j] += inc;
10964 word f = floor(xtra[j]);
10965 xtra[j] -= f;
10966 if(toFill[j] > f)
10967 {
10968 toFill[j] -= f;
10969 game->change_counter(f,bt->counter[j]);
10970 }
10971 else if(toFill[j])
10972 {
10973 game->change_counter(toFill[j],bt->counter[j]);
10974 toFill[j] = 0;
10975 }
10976 }
10977 do_refill_waitframe();
10978 }
10979 for(size_t j = 0; j < 3; ++j)
10980 {
10981 if(toFill[j])
10982 {
10983 game->change_counter(toFill[j],bt->counter[j]);
10984 toFill[j] = 0;
10985 }
10986 }
10987 for(size_t q = 0; q < 20; ++q)
10988 do_refill_waitframe();
10989 game->set_bottle_slot(itm.misc1, bt->next_type);
10990 }
10991 }
10992
10993 dowpn = -1;
10994 ret = false;
10995 break;
10996 }
10997
10998 case itype_note:
10999 {
11000 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11001 {
11002 if(QMisc.miscsfx[sfxERROR])
11003 sfx(QMisc.miscsfx[sfxERROR]);
11004 return false;
11005 }
11006 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
11007 {
11008 sfx(itm.usesound);
11009 donewmsg(itm.misc1);
11010 paymagiccost(itemid);
11011 }
11012 dowpn = -1;
11013 ret = false;
11014 break;
11015 }
11016
11017 case itype_mirror:
11018 doMirror(itemid);
11019 if(Quit)
11020 return false;
11021 ret = false;
11022 break;
11023
11024 case itype_rocs:
11025 {
11026
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 5 times.
59 if(!do_jump(itemid,false)) return false;
11027 54 ret = false;
11028 }
11029 54 break;
11030
11031 case itype_letter:
11032 {
11033 if(current_item(itype_letter)==i_letter &&
11034 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11035 tmpscr[currscr<128?0:1].guy &&
11036 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11037 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11038 checkbunny(itemid)
11039 )
11040 {
11041 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11042
11043 if(usedid != -1)
11044 getitem(usedid, true, true);
11045
11046 sfx(tmpscr[currscr<128?0:1].secretsfx);
11047 setupscreen();
11048 action=none; FFCore.setHeroAction(none);
11049 }
11050
11051 ret = false;
11052 }
11053 break;
11054
11055 case itype_whistle:
11056 {
11057 bool whistleflag;
11058
11059 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11060 {
11061 if(QMisc.miscsfx[sfxERROR])
11062 sfx(QMisc.miscsfx[sfxERROR]);
11063 return false;
11064 }
11065
11066 paymagiccost(itemid);
11067 sfx(itm.usesound);
11068
11069 if(dir==up || dir==right)
11070 ++blowcnt;
11071 else
11072 --blowcnt;
11073
11074 int sfx_count = 0;
11075 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
11076 {
11077 sfx_count += 1;
11078 advanceframe(true);
11079
11080 if(Quit)
11081 return false;
11082 }
11083
11084 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11085
11086 if((whistleflag=findentrance(x,y,mfWHISTLE,get_bit(quest_rules, qr_PERMANENT_WHISTLE_SECRETS))))
11087 didstuff |= did_whistle;
11088
11089 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11090 return false;
11091
11092 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11093
11094 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11095 || (tmpscr->flags7&fWHISTLEPAL))
11096 {
11097 whistleclk=0; // signal to start drying lake or doing other stuff
11098 }
11099 else
11100 {
11101 int32_t where = itm.misc1;
11102
11103 if(where>right) where=dir^1;
11104
11105 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11106 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11107 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
11108 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
11109 (zfix)0,
11110 wWind,
11111 0, //type
11112 0,
11113 where,
11114 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11115
11116 whistleitem=itemid;
11117 }
11118
11119 ret = false;
11120 }
11121 break;
11122
11123 case itype_bomb:
11124 {
11125 //Remote detonation
11126
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
5 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11127 {
11128 1 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11129
11130
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11131 {
11132 //If this ever needs a version check, in the future. -z
11133 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11134 {
11135 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11136 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11137 }
11138 ew->misc=50;
11139 ew->clk=ew->misc-3;
11140 ew->id=wBomb;
11141 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11142 }
11143
11144 1 deselectbombs(false);
11145 1 return false;
11146 }
11147
11148
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11149 {
11150 if(QMisc.miscsfx[sfxERROR])
11151 sfx(QMisc.miscsfx[sfxERROR]);
11152 return false;
11153 }
11154
11155 4 paymagiccost(itemid);
11156
11157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(itm.misc1>0) // If not remote bombs
11158 4 deselectbombs(false);
11159
11160
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(isdungeon())
11161 {
11162 wy=zc_max(wy,16);
11163 }
11164
11165
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
8 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11166
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11167 4 sfx(WAV_PLACE,pan(wx));
11168 }
11169 4 break;
11170
11171 case itype_sbomb:
11172 {
11173 //Remote detonation
11174 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11175 {
11176 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11177
11178 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11179 {
11180 ew->misc=50;
11181 ew->clk=ew->misc-3;
11182 ew->id=wSBomb;
11183 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11184 }
11185
11186 deselectbombs(true);
11187 return false;
11188 }
11189
11190 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11191 {
11192 if(QMisc.miscsfx[sfxERROR])
11193 sfx(QMisc.miscsfx[sfxERROR]);
11194 return false;
11195 }
11196
11197 paymagiccost(itemid);
11198
11199 if(itm.misc1>0) // If not remote bombs
11200 deselectbombs(true);
11201
11202 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true));
11203 sfx(WAV_PLACE,pan(wx));
11204 }
11205 break;
11206
11207 case itype_wand:
11208 {
11209 if(Lwpns.idCount(wMagic))
11210 {
11211 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11212 return false;
11213 }
11214
11215 int32_t bookid = current_item_id(itype_book);
11216 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11217
11218 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11219 {
11220 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11221 return false;
11222 }
11223
11224 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11225 {
11226 if(QMisc.miscsfx[sfxERROR])
11227 sfx(QMisc.miscsfx[sfxERROR]);
11228 return false;
11229 }
11230
11231 if(Lwpns.idCount(wBeam))
11232 Lwpns.del(Lwpns.idFirst(wBeam));
11233
11234 int32_t type, pow;
11235 if ( get_bit(quest_rules,qr_BROKENBOOKCOST) )
11236 {
11237 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11238 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11239 }
11240 else
11241 {
11242 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11243 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11244 }
11245 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11246 if(dir!=(i^1))
11247 {
11248 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11249 if(paybook)
11250 magic->linkedItem = bookid;
11251 //magic->dir = this->dir; //Save player dir for special weapons.
11252 Lwpns.add(magic);
11253 }
11254 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11255 paymagiccost(itemid);
11256 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11257
11258 if(paybook)
11259 paymagiccost(current_item_id(itype_book));
11260
11261 if(bookid != -1)
11262 {
11263 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11264 {
11265 sfx(itemsbuf[bookid].misc2,pan(wx));
11266 }
11267 else
11268 {
11269 sfx(itm.usesound,pan(wx));
11270 }
11271 }
11272 else
11273 sfx(itm.usesound,pan(wx));
11274 }
11275 /*
11276 // Fireball Wand
11277 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11278 switch (dir)
11279 {
11280 case up:
11281 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11282 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11283 break;
11284 case down:
11285 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11286 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11287 break;
11288 case left:
11289 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11290 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11291 break;
11292 case right:
11293 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11294 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11295 break;
11296 }
11297 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11298 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11299 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11300 */
11301 break;
11302
11303 case itype_sword:
11304 {
11305
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
320 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11306 {
11307 if(QMisc.miscsfx[sfxERROR])
11308 sfx(QMisc.miscsfx[sfxERROR]);
11309 return false;
11310 }
11311
11312
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 262 times.
320 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11313 {
11314 58 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11315 58 return false;
11316 }
11317
11318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 262 times.
262 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11319 262 paymagiccost(itemid);
11320 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11321 float temppower;
11322
11323
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
262 if(itm.flags & ITEM_FLAG2)
11324 {
11325 262 temppower=game->get_hero_dmgmult()*itm.power;
11326 262 temppower=temppower*itm.misc2;
11327 262 temppower=temppower/100;
11328 262 }
11329 else
11330 {
11331 temppower = game->get_hero_dmgmult()*itm.misc2;
11332 }
11333
11334 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11335 //Add weapon script to sword beams.
11336
5/10
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 262 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 262 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 262 times.
✗ Branch 9 not taken.
262 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11337 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11338 //w->weaponscript = itm.weaponscript;
11339 //w->canrunscript = 0;
11340 262 sfx(WAV_BEAM,pan(wx));
11341 }
11342 262 break;
11343
11344 case itype_candle:
11345 {
11346 int32_t countid = itemid;
11347 if(get_bit(quest_rules, qr_CANDLES_SHARED_LIMIT))
11348 countid = -itype_candle;
11349 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11350 {
11351 return false;
11352 }
11353
11354 if(Lwpns.idCount(wFire) >= (itm.misc3 < 1 ? 2 : itm.misc3))
11355 {
11356 return false;
11357 }
11358
11359 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11360 {
11361 if(QMisc.miscsfx[sfxERROR])
11362 sfx(QMisc.miscsfx[sfxERROR]);
11363 return false;
11364 }
11365
11366 paymagiccost(itemid);
11367
11368 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11369
11370 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11371 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11372 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11373 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11374 sfx(itm.usesound,pan(wx));
11375 attack=wFire;
11376 }
11377 break;
11378
11379 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11380 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11381 {
11382 int32_t wtype = wScript1 + (itm.family-itype_script1);
11383 if(Lwpns.idCount(wtype))
11384 return false;
11385
11386 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11387 {
11388 if(QMisc.miscsfx[sfxERROR])
11389 sfx(QMisc.miscsfx[sfxERROR]);
11390 return false;
11391 }
11392
11393 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11394 paymagiccost(itemid);
11395
11396 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11397 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11398 sfx(itm.usesound,pan(wx));
11399 }
11400 break;
11401
11402 case itype_icerod:
11403 {
11404 if(Lwpns.idCount(wIce))
11405 return false;
11406
11407 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11408 {
11409 if(QMisc.miscsfx[sfxERROR])
11410 sfx(QMisc.miscsfx[sfxERROR]);
11411 return false;
11412 }
11413
11414 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11415 paymagiccost(itemid);
11416
11417 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11418 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11419 sfx(itm.usesound,pan(wx));
11420 }
11421 break;
11422
11423 case itype_arrow:
11424 {
11425 if(Lwpns.idCount(wArrow) > itm.misc2)
11426 return false;
11427
11428 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11429 {
11430 if(QMisc.miscsfx[sfxERROR])
11431 sfx(QMisc.miscsfx[sfxERROR]);
11432 return false;
11433 }
11434
11435 paymagiccost(itemid);
11436
11437 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11438 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11439 sfx(itm.usesound,pan(wx));
11440 }
11441 break;
11442
11443 case itype_bait:
11444 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11445 return false;
11446
11447 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11448 {
11449 if(QMisc.miscsfx[sfxERROR])
11450 sfx(QMisc.miscsfx[sfxERROR]);
11451 return false;
11452 }
11453
11454 paymagiccost(itemid);
11455 sfx(itm.usesound,pan(wx));
11456
11457 if(tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
11458 {
11459 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,iBait,ipDUMMY+ipFADE,0));
11460 fadeclk=66;
11461 dismissmsg();
11462 clear_bitmap(pricesdisplaybuf);
11463 set_clip_state(pricesdisplaybuf, 1);
11464 // putscr(scrollbuf,0,0,tmpscr);
11465 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11466 removeItemsOfFamily(game,itemsbuf,itype_bait);
11467 verifyBothWeapons();
11468 sfx(tmpscr->secretsfx);
11469 return false;
11470 }
11471
11472 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11473 break;
11474
11475 case itype_brang:
11476 {
11477
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 157 times.
168 if(Lwpns.idCount(wBrang) > itm.misc2)
11478 11 return false;
11479
11480
2/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 157 times.
157 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11481 {
11482 if(QMisc.miscsfx[sfxERROR])
11483 sfx(QMisc.miscsfx[sfxERROR]);
11484 return false;
11485 }
11486
11487 157 paymagiccost(itemid);
11488 157 current_item_power(itype_brang);
11489
6/12
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 157 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 157 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 157 times.
✗ Branch 11 not taken.
157 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11490 }
11491 157 break;
11492
11493 case itype_hookshot:
11494 case itype_switchhook:
11495 {
11496 if(inlikelike || Lwpns.idCount(wHookshot))
11497 return false;
11498
11499 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11500 {
11501 if(QMisc.miscsfx[sfxERROR])
11502 sfx(QMisc.miscsfx[sfxERROR]);
11503 return false;
11504 }
11505 bool sw = itm.family == itype_switchhook;
11506
11507 if(sw && (itm.flags&ITEM_FLAG8))
11508 switchhook_cost_item = itemid;
11509 else paymagiccost(itemid);
11510
11511 bool use_hookshot=true;
11512 bool hit_hs = false, hit_solid = false, insta_switch = false;
11513 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11514 int32_t cpos = -1, ffcpos = -1;
11515 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11516 {
11517 if(dir==up)
11518 {
11519 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11520 hit_hs = true;
11521 }
11522 else if(dir==down)
11523 {
11524 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11525 hit_hs = true;
11526 }
11527 else if(dir==left)
11528 {
11529 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11530 hit_hs = true;
11531 }
11532 else if(dir==right)
11533 {
11534 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11535 hit_hs = true;
11536 }
11537 //Diagonal Hookshot (6)
11538 else if(dir==r_down)
11539 {
11540 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11541 hit_hs = true;
11542 }
11543 else if(dir==l_down)
11544 {
11545 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11546 hit_hs = true;
11547 }
11548 else if(dir==r_up)
11549 {
11550 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11551 hit_hs = true;
11552 }
11553 else if(dir==l_up)
11554 {
11555 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11556 hit_hs = true;
11557 }
11558 }
11559 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11560 hit_solid = true;
11561 if(hit_hs)
11562 {
11563 if(sw)
11564 insta_switch = true; //switch immediately
11565 else use_hookshot = false; //No hooking against grabbable
11566 }
11567 if(hit_solid && !insta_switch)
11568 use_hookshot = false;
11569 if(use_hookshot)
11570 {
11571 int32_t hookitem = itm.fam_type;
11572 int32_t hookpower = itm.power;
11573 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11574
11575 if(!Lwpns.has_space())
11576 {
11577 Lwpns.del(0);
11578 }
11579
11580 if(!Lwpns.has_space(2))
11581 {
11582 Lwpns.del(0);
11583 }
11584
11585 switch(dir)
11586 {
11587 case up:
11588 {
11589 hookshot_used=true;
11590 hs_switcher = sw;
11591 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11592 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11593 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11594 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11595 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11596 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11597 hs_startx=wx;
11598 hs_starty=wy-4;
11599 }
11600 break;
11601
11602 case down:
11603 {
11604 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11605 hookshot_used=true;
11606 hs_switcher = sw;
11607 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11608 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11609 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11610 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11611 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11612 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11613 hs_startx=wx;
11614 hs_starty=wy;
11615 }
11616 break;
11617
11618 case left:
11619 {
11620 hookshot_used=true;
11621 hs_switcher = sw;
11622 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11623 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11624 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11625 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11626 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11627 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11628 hs_startx=wx-4;
11629 hs_starty=wy;
11630 }
11631 break;
11632
11633 case right:
11634 {
11635 hookshot_used=true;
11636 hs_switcher = sw;
11637 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11638 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11639 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11640 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11641 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11642 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11643 hs_startx=wx+4;
11644 hs_starty=wy;
11645 }
11646 break;
11647 //Diagonal Hookshot (7)
11648 case r_down:
11649 {
11650 hookshot_used=true;
11651 hs_switcher = sw;
11652 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11653 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11654 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11655 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11656 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11657 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11658 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11659 hs_startx=wx+4;
11660 hs_starty=wy;
11661 }
11662 break;
11663
11664 case r_up:
11665 {
11666 hookshot_used=true;
11667 hs_switcher = sw;
11668 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11669 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11670 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11671 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11672 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11673 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11674 hs_startx=wx+4;
11675 hs_starty=wy;
11676 }
11677 break;
11678
11679 case l_down:
11680 {
11681 hookshot_used=true;
11682 hs_switcher = sw;
11683 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11684 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11685 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11686 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11687 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11688 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11689 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11690 hs_startx=wx+4;
11691 hs_starty=wy;
11692 }
11693 break;
11694
11695 case l_up:
11696 {
11697 hookshot_used=true;
11698 hs_switcher = sw;
11699 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11700 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11701 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11702 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11703 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11704 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11705 hs_startx=wx+4;
11706 hs_starty=wy;
11707 }
11708 break;
11709 }
11710 hookshot_frozen=true;
11711 }
11712 if(insta_switch)
11713 {
11714 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11715 if (cpos > -1) hooked_combopos = cpos;
11716 if (ffcpos > -1)
11717 {
11718 switching_object = &(tmpscr->ffcs[ffcpos]);
11719 switching_object->switch_hooked = true;
11720 }
11721 w->misc=2;
11722 w->step=0;
11723 doSwitchHook(itm.misc5);
11724 if(itm.usesound2)
11725 sfx(itm.usesound2,pan(int32_t(x)));
11726 else if(QMisc.miscsfx[sfxSWITCHED])
11727 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11728 stop_sfx(itm.usesound);
11729 }
11730 }
11731 break;
11732
11733 case itype_dinsfire:
11734 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11735 return false;
11736
11737 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11738 {
11739 if(QMisc.miscsfx[sfxERROR])
11740 sfx(QMisc.miscsfx[sfxERROR]);
11741 return false;
11742 }
11743
11744 paymagiccost(itemid);
11745 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11746 else {action=casting; FFCore.setHeroAction(casting);}
11747 magicitem=itemid;
11748 break;
11749
11750 case itype_faroreswind:
11751 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11752 return false;
11753
11754 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11755 {
11756 if(QMisc.miscsfx[sfxERROR])
11757 sfx(QMisc.miscsfx[sfxERROR]);
11758 return false;
11759 }
11760
11761 paymagiccost(itemid);
11762 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11763 else {action=casting; FFCore.setHeroAction(casting);}
11764 magicitem=itemid;
11765 break;
11766
11767 case itype_nayruslove:
11768 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11769 return false;
11770
11771 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11772 {
11773 if(QMisc.miscsfx[sfxERROR])
11774 sfx(QMisc.miscsfx[sfxERROR]);
11775 return false;
11776 }
11777
11778 paymagiccost(itemid);
11779 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11780 else {action=casting; FFCore.setHeroAction(casting);}
11781 magicitem=itemid;
11782 break;
11783
11784 case itype_cbyrna:
11785 {
11786 //Beams already deployed
11787 if(Lwpns.idCount(wCByrna))
11788 {
11789 stopCaneOfByrna();
11790 return false;
11791 }
11792
11793 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11794 {
11795 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
11796 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
11797 return false;
11798 }
11799
11800 paymagiccost(itemid);
11801 last_cane_of_byrna_item_id = itemid;
11802 //zprint("itm.misc3: %d\n", itm.misc3);
11803 for(int32_t i=0; i<itm.misc3; i++)
11804 {
11805 //byrna weapons are added here
11806 //space them apart
11807 //zprint("Added byrna weapon %d.\n", i);
11808 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
11809 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
11810 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11811 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11812 //wx += cos(2 * PI / (itm.misc3-i));
11813 //wy += sin(2 * PI / (itm.misc3-i));
11814 }
11815 if(!(Lwpns.idCount(wCByrna)))
11816 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
11817 }
11818 break;
11819
11820 case itype_clock:
11821 {
11822 ret = false;
11823 if(!(itm.flags & ITEM_FLAG1))
11824 break; //Passive clock, don't use
11825 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
11826 break;
11827 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
11828 {
11829 if(QMisc.miscsfx[sfxERROR])
11830 sfx(QMisc.miscsfx[sfxERROR]);
11831 return false;
11832 }
11833
11834 paymagiccost(itemid);
11835
11836 setClock(watch=true);
11837
11838 for(int32_t i=0; i<eMAXGUYS; i++)
11839 clock_zoras[i]=0;
11840
11841 clockclk=itm.misc1;
11842 sfx(itm.usesound);
11843 break;
11844 }
11845 case itype_killem:
11846 {
11847 ret = false;
11848 if(!(itm.flags & ITEM_FLAG1))
11849 break; //Passive killemall, don't use
11850
11851 if(!(checkbunny(itemid) && checkmagiccost(itemid))
11852 || !can_kill_em_all()) //No enemies onscreen
11853 {
11854 if(QMisc.miscsfx[sfxERROR])
11855 sfx(QMisc.miscsfx[sfxERROR]);
11856 return false;
11857 }
11858
11859 paymagiccost(itemid);
11860
11861 kill_em_all();
11862 sfx(itm.usesound);
11863 break;
11864 }
11865 case itype_refill:
11866 {
11867 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11868 {
11869 if(QMisc.miscsfx[sfxERROR])
11870 sfx(QMisc.miscsfx[sfxERROR]);
11871 return false;
11872 }
11873
11874 bool did_something = false;
11875
11876 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
11877 {
11878 if(swordclk)
11879 did_something = true;
11880 swordclk = 0;
11881 verifyAWpn();
11882 }
11883 for(auto q = 0; q < 5; ++q)
11884 {
11885 auto ctr = itm.misc(q);
11886 if(unsigned(ctr) >= MAX_COUNTERS)
11887 continue;
11888 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
11889 if(!amnt) continue;
11890 bool gradual = itm.flags & ITEM_FLAG2;
11891 if(amnt > 0)
11892 {
11893 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
11894 {
11895 //Can't *do* anything... skip
11896 continue;
11897 }
11898 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
11899 {
11900 //Can't do anything unless affecting dcounter
11901 gradual = true;
11902 }
11903 }
11904 else //Negative
11905 {
11906 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
11907 {
11908 //Can't *do* anything... skip
11909 continue;
11910 }
11911 if(game->get_counter(ctr) <= 0)
11912 {
11913 //Can't do anything unless affecting dcounter
11914 gradual = true;
11915 }
11916 }
11917 did_something = true;
11918 if(gradual) //Gradual
11919 {
11920 game->change_dcounter(amnt, ctr);
11921 }
11922 else
11923 {
11924 game->change_counter(amnt, ctr);
11925 }
11926 }
11927 if(!did_something)
11928 {
11929 if(QMisc.miscsfx[sfxERROR])
11930 sfx(QMisc.miscsfx[sfxERROR]);
11931 return false;
11932 }
11933 paymagiccost(itemid);
11934 sfx(itm.usesound);
11935 ret = false;
11936 break;
11937 }
11938
11939 default:
11940 ret = false;
11941 }
11942
11943
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 if(itm.flags & ITEM_DOWNGRADE)
11944 {
11945 game->set_item(itemid,false);
11946
11947 // Maybe Item Override has allowed the same item in both slots?
11948 if(Bwpn == itemid)
11949 {
11950 Bwpn = 0;
11951 game->forced_bwpn = -1;
11952 verifyBWpn();
11953 }
11954
11955 if(Awpn == itemid)
11956 {
11957 Awpn = 0;
11958 game->forced_awpn = -1;
11959 verifyAWpn();
11960 }
11961
11962 if(Xwpn == itemid)
11963 {
11964 Xwpn = 0;
11965 game->forced_xwpn = -1;
11966 verifyXWpn();
11967 }
11968
11969 if(Ywpn == itemid)
11970 {
11971 Ywpn = 0;
11972 game->forced_ywpn = -1;
11973 verifyYWpn();
11974 }
11975 }
11976
11977 477 return ret;
11978 552 }
11979
11980
11981 10670 bool HeroClass::doattack()
11982 {
11983 //int32_t s = BSZ ? 0 : 11;
11984 10670 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
11985
11986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10670 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
11987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10670 if(attack==wBugNet && bugnetid!=-1)
11988 {
11989 if(++attackclk >= NET_CLK_TOTAL)
11990 return false;
11991
11992 return true;
11993 }
11994
11995 // Abort attack if attackclk has run out and:
11996 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
11997 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
11998
11999
5/6
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 10148 times.
✓ Branch 2 taken 522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 4 times.
10681 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12000
10/12
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 426 times.
✓ Branch 4 taken 511 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 511 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 4 times.
522 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12001 {
12002 515 tapping=false;
12003 515 return false;
12004 }
12005
12006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10155 times.
10155 if(attackclk>29)
12007 {
12008 tapping=false;
12009 return false;
12010 }
12011
12012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10155 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10155 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12014 // An attack can be "walked out-of" after 8 frames, unless it's:
12015 // * a sword stab
12016 // * a hammer pound
12017 // * a wand thrust
12018 // * a candle thrust
12019 // * a cane thrust
12020 // In which case it should continue.
12021
8/8
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 9441 times.
✓ Branch 2 taken 1524 times.
✓ Branch 3 taken 810 times.
✓ Branch 4 taken 8488 times.
✓ Branch 5 taken 1763 times.
✓ Branch 6 taken 2349 times.
✓ Branch 7 taken 6139 times.
12504 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12022
2/6
✓ Branch 0 taken 2349 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2349 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2349 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2349 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2349 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12024
1/2
✓ Branch 0 taken 2349 times.
✗ Branch 1 not taken.
2349 && (attack != wBugNet) && attackclk>7))
12025 {
12026
8/8
✓ Branch 0 taken 776 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 747 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 704 times.
✓ Branch 5 taken 43 times.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 654 times.
3873 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12027 {
12028 171 lstep = s;
12029 171 return false;
12030 }
12031 654 }
12032
12033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8556 times.
8556 if(charging==0)
12034 {
12035 8556 lstep=0;
12036 8556 }
12037
12038 // Work out the sword charge-up delay
12039 8556 int32_t magiccharge = 192, normalcharge = 64;
12040 8556 int32_t itemid = current_item_id(itype_chargering);
12041
12042
1/2
✓ Branch 0 taken 8556 times.
✗ Branch 1 not taken.
8556 if(itemid>=0)
12043 {
12044 normalcharge = itemsbuf[itemid].misc1;
12045 magiccharge = itemsbuf[itemid].misc2;
12046 }
12047
12048 8556 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12049
12050 8556 bool doCharge=true;
12051
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8556 if(z!=0 && fakez != 0)
12052 doCharge=false;
12053
2/2
✓ Branch 0 taken 6139 times.
✓ Branch 1 taken 2417 times.
8556 if(attack==wSword)
12054 {
12055
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6139 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12056 6139 doCharge=false;
12057 else if(charging<=normalcharge)
12058 {
12059 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
12060 doCharge=false;
12061 }
12062 6139 }
12063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2417 times.
2417 else if(attack==wHammer)
12064 {
12065 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12066 doCharge=false;
12067 else if(charging<=normalcharge)
12068 {
12069 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
12070 doCharge=false;
12071 }
12072 }
12073 else
12074 2417 doCharge=false;
12075
12076 // Now work out the magic cost
12077 8556 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12078
12079 // charging up weapon...
12080 //
12081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8556 times.
8556 if(doCharge)
12082 {
12083 // Increase charging while holding down button.
12084 if(spins==0 && charging<magiccharge)
12085 charging++;
12086
12087 // Once a charging threshold is reached, play the sound.
12088 if(charging==normalcharge)
12089 {
12090 paymagiccost(itemid); //!DIMITODO: Can this underflow or even just do it even if you don't have magic?
12091 sfx(WAV_ZN1CHARGE,pan(x.getInt()));
12092 }
12093 else if(charging==magiccharge)
12094 {
12095 itemid = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12096
12097 if(itemid>-1 && checkbunny(itemid) && checkmagiccost(itemid))
12098 {
12099 paymagiccost(itemid);
12100 charging++; // charging>magiccharge signifies a successful supercharge.
12101 sfx(WAV_ZN1CHARGE2,pan(x.getInt()));
12102 }
12103 }
12104 }
12105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8556 else if(attack==wCByrna && byrnaid!=-1)
12106 {
12107 if(!(itemsbuf[byrnaid].wpn))
12108 {
12109 attack = wNone;
12110 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12111 }
12112
12113 bool beamcount = false;
12114
12115 for(int32_t i=0; i<Lwpns.Count(); i++)
12116 {
12117 weapon *w = ((weapon*)Lwpns.spr(i));
12118
12119 if(w->id==wCByrna)
12120 {
12121 beamcount = true;
12122 break;
12123 }
12124 }
12125
12126 // If beams already deployed, remove them
12127 if(!attackclk && beamcount)
12128 {
12129 return startwpn(attackid); // Remove beams instantly
12130 }
12131
12132 // Otherwise, continue
12133 ++attackclk;
12134 }
12135 else
12136 {
12137 8556 ++attackclk;
12138
12139
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8556 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12140 {
12141 ++attackclk; // Won't continue charging
12142 charging=0;
12143 }
12144
12145 // Faster if spinning.
12146
1/2
✓ Branch 0 taken 8556 times.
✗ Branch 1 not taken.
8556 if(spins>0)
12147 ++attackclk;
12148
12149 // Even faster if hurricane spinning.
12150
1/2
✓ Branch 0 taken 8556 times.
✗ Branch 1 not taken.
8556 if(spins>5)
12151 attackclk+=2;
12152
12153 // If at a charging threshold, do a charged attack.
12154
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8556 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12155 {
12156 if(attack==wSword)
12157 {
12158 spins=(charging>magiccharge ? (itemsbuf[current_item_id(itype_spinscroll2)].misc1*4)-3
12159 : (itemsbuf[current_item_id(itype_spinscroll)].misc1*4)+1);
12160 attackclk=1;
12161 sfx(itemsbuf[current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
12162 }
12163 /*
12164 else if(attack==wWand)
12165 {
12166 //Not reachable.. yet
12167 spins=1;
12168 }
12169 */
12170 else if(attack==wHammer && sideviewhammerpound())
12171 {
12172 spins=1; //signifies the quake hammer
12173 bool super = (charging>magiccharge && current_item(itype_quakescroll2));
12174 sfx(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].usesound,pan(x.getInt()));
12175 quakeclk=(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc1);
12176
12177 // general area stun
12178 for(int32_t i=0; i<GuyCount(); i++)
12179 {
12180 if(!isflier(GuyID(i)))
12181 {
12182 StunGuy(i,(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc2)-
12183 distance(x,y,GuyX(i),GuyY(i)));
12184 }
12185 }
12186 }
12187 }
12188
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8556 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12189 charging++;
12190
12191
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8556 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8556 times.
✓ Branch 6 taken 4979 times.
✓ Branch 7 taken 3577 times.
8556 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12192 3577 charging=0;
12193
12194
1/2
✓ Branch 0 taken 8556 times.
✗ Branch 1 not taken.
8556 if(attackclk>=SWORDCHARGEFRAME)
12195 tapping = false;
12196 }
12197
12198
3/8
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 7856 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 700 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8556 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12199 {
12200 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12201 }
12202
12203 8556 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12204
12205
5/12
✓ Branch 0 taken 8032 times.
✓ Branch 1 taken 524 times.
✓ Branch 2 taken 622 times.
✓ Branch 3 taken 7410 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 622 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8556 if(attackclk==13 || (attackclk==7 && spins>1 && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12206 {
12207
12208
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
524 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12209
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 16 times.
524 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12210
12211
3/4
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 508 times.
524 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12212 {
12213 508 templife=templife*game->get_maxlife();
12214 508 templife=templife/100;
12215 508 }
12216 else
12217 {
12218 16 templife*=game->get_hp_per_heart();
12219 }
12220
12221
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 211 times.
524 bool normalbeam = (int64_t(game->get_life())+(get_bit(quest_rules,qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12222 524 int32_t perilid = current_item_id(itype_perilscroll);
12223
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 518 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
524 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12224
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 && checkbunny(perilid) && checkmagiccost(perilid)
12225 // Must actually be able to shoot sword beams
12226 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12227 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12228
12229
3/4
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 91 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
524 if(attack==wSword && !tapping)
12230 {
12231
3/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 113 times.
433 if(perilbeam || normalbeam)
12232 {
12233
1/2
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
320 if(attackclk==7)
12234 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12235
12236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
320 if(perilbeam && !normalbeam)
12237 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12238
12239 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12240 // a way to make the peril/cross beam item's power stat influence the strength
12241 // of the peril/cross beam...
12242 320 startwpn(attackid);
12243 320 }
12244 113 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12245 433 }
12246
12247
1/2
✓ Branch 0 taken 524 times.
✗ Branch 1 not taken.
524 if(attack==wWand)
12248 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12249
12250
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
524 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12251 startwpn(attackid);
12252
12253
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
524 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12254 startwpn(attackid);
12255 524 }
12256
12257
2/2
✓ Branch 0 taken 8040 times.
✓ Branch 1 taken 516 times.
8556 if(attackclk==14)
12258 516 lstep = s;
12259
12260 8556 return true;
12261 9242 }
12262
12263 151472 bool HeroClass::can_attack()
12264 {
12265
3/4
✓ Branch 0 taken 151472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97608 times.
✓ Branch 3 taken 53864 times.
151472 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12266
4/6
✓ Branch 0 taken 151472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150920 times.
✓ Branch 3 taken 552 times.
✓ Branch 4 taken 150920 times.
✗ Branch 5 not taken.
161480 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12267
4/8
✓ Branch 0 taken 150920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150920 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150920 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150920 times.
✗ Branch 7 not taken.
150920 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12268
3/4
✓ Branch 0 taken 150920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133214 times.
✓ Branch 3 taken 17706 times.
150920 || ((action==attacking||action==sideswimattacking)
12269
2/2
✓ Branch 0 taken 5004 times.
✓ Branch 1 taken 145916 times.
150920 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12270
2/2
✓ Branch 0 taken 150920 times.
✓ Branch 1 taken 5004 times.
150920 && charging!=0))
12271 {
12272 10560 return false;
12273 }
12274
12275 150920 int32_t r = (isdungeon()) ? 16 : 0;
12276 150920 int32_t r2 = get_bit(quest_rules, qr_NOBORDER) ? 0 : 8;
12277
12278
4/5
✓ Branch 0 taken 91372 times.
✓ Branch 1 taken 59548 times.
✓ Branch 2 taken 22178 times.
✓ Branch 3 taken 37370 times.
✗ Branch 4 not taken.
150920 if(!get_bit(quest_rules, qr_ITEMSONEDGES)) switch(dir)
12279 {
12280 case up:
12281 case down:
12282
2/2
✓ Branch 0 taken 21550 times.
✓ Branch 1 taken 628 times.
22178 return !(y<(r2+r) || y>(160-r-r2));
12283
12284 case left:
12285 case right:
12286
2/2
✓ Branch 0 taken 36828 times.
✓ Branch 1 taken 542 times.
37370 return !(x<(r2+r) || x>(240-r-r2));
12287 }
12288
12289 91372 return true;
12290 161480 }
12291
12292 bool isRaftFlag(int32_t flag)
12293 {
12294 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12295 }
12296
12297 75737 void handle_lens_triggers(int32_t l_id)
12298 {
12299
1/2
✓ Branch 0 taken 75737 times.
✗ Branch 1 not taken.
75737 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12300
2/2
✓ Branch 0 taken 75737 times.
✓ Branch 1 taken 530159 times.
605896 for(auto layer = 0; layer < 7; ++layer)
12301 {
12302 530159 mapscr* tmp = FFCore.tempScreens[layer];
12303
2/2
✓ Branch 0 taken 93307984 times.
✓ Branch 1 taken 530159 times.
93838143 for(auto pos = 0; pos < 176; ++pos)
12304 {
12305 93307984 newcombo const& cmb = combobuf[tmp->data[pos]];
12306
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93307984 times.
✓ Branch 2 taken 93307984 times.
✗ Branch 3 not taken.
93307984 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12307 93307984 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12308 {
12309 do_trigger_combo(layer, pos);
12310 }
12311 93307984 }
12312 530159 }
12313
2/2
✓ Branch 0 taken 62959 times.
✓ Branch 1 taken 12778 times.
75737 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
12314 {
12315 12778 word c = tmpscr->numFFC();
12316
2/2
✓ Branch 0 taken 12778 times.
✓ Branch 1 taken 204477 times.
217255 for(word i=0; i<c; i++)
12317 {
12318 204477 ffcdata& ffc = tmpscr->ffcs[i];
12319 204477 newcombo const& cmb = combobuf[ffc.getData()];
12320
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 204477 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204477 times.
204477 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12321 204477 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12322 {
12323 do_trigger_combo_ffc(i);
12324 break;
12325 }
12326 204477 }
12327 12778 }
12328 75737 }
12329
12330 75737 void do_lens()
12331 {
12332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75737 times.
75737 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12333 {
12334 do_210_lens();
12335 return;
12336 }
12337
12338 75737 int32_t wpnPressed = getWpnPressed(itype_lens);
12339
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 75737 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75737 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 75737 times.
75737 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12340
2/2
✓ Branch 0 taken 75174 times.
✓ Branch 1 taken 563 times.
75737 if(itemid >= 0)
12341 {
12342
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 563 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
563 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12343 {
12344 if(lensid<0)
12345 {
12346 lensid=itemid;
12347 if(itemsbuf[itemid].family == itype_lens)
12348 Hero.setLastLensID(itemid);
12349 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12350 }
12351
12352 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12353
12354 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12355 {
12356 //clear the item script stack for a new script
12357 //itemScriptData[(itemid & 0xFFF)].Clear();
12358 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12359 ri = &(itemScriptData[itemid]);
12360 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12361 ri->Clear();
12362 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12363 item_doscript[itemid] = 1;
12364 itemscriptInitialised[itemid] = 0;
12365 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12366 did_scriptl=true;
12367 }
12368
12369 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12370 else lensclk = 12;
12371 }
12372 else
12373 {
12374 563 did_scriptl=false;
12375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 563 times.
563 if(!lensclk)
12376 {
12377
12378
1/2
✓ Branch 0 taken 563 times.
✗ Branch 1 not taken.
563 if(lensid>-1)
12379 {
12380 lensid=-1;
12381 lensclk = 0;
12382
12383 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12384 }
12385 563 }
12386 }
12387 563 }
12388 75737 handle_lens_triggers(lensid);
12389 75737 }
12390 //Add 2.10 version check to call this
12391 void do_210_lens()
12392 {
12393 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12394
12395 if(itemid<0)
12396 return;
12397
12398 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12399 {
12400 if(lensid<0)
12401 {
12402 lensid=itemid;
12403
12404 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12405 }
12406
12407 paymagiccost(itemid, true);
12408
12409 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12410 {
12411 //clear the item script stack for a new script
12412 //itemScriptData[(itemid & 0xFFF)].Clear();
12413 ri = &(itemScriptData[itemid]);
12414 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12415 ri->Clear();
12416 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12417 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12418 item_doscript[itemid] = 1;
12419 itemscriptInitialised[itemid] = 0;
12420 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12421 did_scriptl=true;
12422 }
12423
12424 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12425 else lensclk = 12;
12426 }
12427 else
12428 {
12429 did_scriptl=false;
12430
12431 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12432 {
12433 lensid=-1;
12434 lensclk = 0;
12435
12436 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12437 }
12438 }
12439 }
12440
12441 1 void HeroClass::do_hopping()
12442 {
12443 1 do_lens();
12444
12445
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12446 //Possible fix for exiting water in diagonal movement. -Z
12447 {
12448 1 int32_t flippers_id = current_item_id(itype_flippers);
12449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(diveclk>0)
12450 {
12451 --diveclk;
12452 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12453 {
12454 diveclk = itemsbuf[flippers_id].misc2;
12455 }
12456 }
12457
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else if(DrunkrAbtn())
12458 {
12459 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12460 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12461
12462 if(global_diving==screen_diving)
12463 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12464 }
12465
12466
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12467 {
12468 1 SetSwim();
12469 1 hopclk = 0;
12470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!IsSideSwim())
12471 {
12472 1 charging = attackclk = 0;
12473 1 tapping = false;
12474 1 }
12475 1 }
12476 else
12477 {
12478 herostep();
12479
12480 if(!isDiving() || (frame&1))
12481 {
12482 switch(dir)
12483 {
12484 case up:
12485 y -= 1;
12486 break;
12487
12488 case down:
12489 y += 1;
12490 break;
12491
12492 case left:
12493 x -= 1;
12494 break;
12495
12496 case right:
12497 x += 1;
12498 break;
12499 }
12500 }
12501 }
12502 1 }
12503 else // hopping in or out (need to separate the cases...)
12504 {
12505 if((diagonalMovement||NO_GRIDLOCK))
12506 {
12507 if(hopclk==1) //hopping out
12508 //>= 1 possible fix for getting stuck on land edges.
12509 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12510 {
12511 if(hopdir!=-1) dir=hopdir;
12512
12513 landswim=0;
12514
12515 if(dir==up)
12516 {
12517 herostep();
12518 herostep();
12519 int32_t sidestep=0;
12520
12521 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12522 sidestep=1;
12523 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12524 sidestep=2;
12525
12526 if(sidestep==1) x++;
12527 else if(sidestep==2) x--;
12528 else y--;
12529
12530 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12531 {
12532 hopclk=0;
12533 diveclk=0;
12534 action=none; FFCore.setHeroAction(none);
12535 hopdir=-1;
12536 }
12537 }
12538
12539 if(dir==down)
12540 {
12541 herostep();
12542 herostep();
12543 int32_t sidestep=0;
12544
12545 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12546 sidestep=1;
12547 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12548 sidestep=2;
12549
12550 if(sidestep==1) x++;
12551 else if(sidestep==2) x--;
12552 else y++;
12553
12554 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12555 {
12556 hopclk=0;
12557 diveclk=0;
12558 action=none; FFCore.setHeroAction(none);
12559 hopdir=-1;
12560 }
12561 }
12562
12563 if(dir==left)
12564 {
12565 herostep();
12566 herostep();
12567 int32_t sidestep=0;
12568
12569 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12570 sidestep=1;
12571 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12572 sidestep=2;
12573
12574 if(sidestep==1) y++;
12575 else if(sidestep==2) y--;
12576 else x--;
12577
12578 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12579 {
12580 hopclk=0;
12581 diveclk=0;
12582 action=none; FFCore.setHeroAction(none);
12583 hopdir=-1;
12584 }
12585 }
12586
12587 if(dir==right)
12588 {
12589 herostep();
12590 herostep();
12591 int32_t sidestep=0;
12592
12593 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12594 sidestep=1;
12595 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12596 sidestep=2;
12597
12598 if(sidestep==1) y++;
12599 else if(sidestep==2) y--;
12600 else x++;
12601
12602 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12603 {
12604 hopclk=0;
12605 diveclk=0;
12606 action=none; FFCore.setHeroAction(none);
12607 hopdir=-1;
12608 }
12609 }
12610 }
12611
12612 if(hopclk==2) //hopping in
12613 {
12614 landswim=0;
12615
12616 if(dir==up)
12617 {
12618 herostep();
12619 herostep();
12620 int32_t sidestep=0;
12621
12622 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12623 sidestep=1;
12624 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12625 sidestep=2;
12626
12627 if(sidestep==1) x++;
12628 else if(sidestep==2) x--;
12629 else y--;
12630
12631 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12632 {
12633 hopclk=0xFF;
12634 diveclk=0;
12635 SetSwim();
12636 }
12637 }
12638
12639 if(dir==down)
12640 {
12641 herostep();
12642 herostep();
12643 int32_t sidestep=0;
12644
12645 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12646 sidestep=1;
12647 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12648 sidestep=2;
12649
12650 if(sidestep==1) x++;
12651 else if(sidestep==2) x--;
12652 else y++;
12653
12654 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12655 {
12656 hopclk=0xFF;
12657 diveclk=0;
12658 SetSwim();
12659 if (!IsSideSwim()) reset_swordcharge();
12660 }
12661 }
12662
12663 if(dir==left)
12664 {
12665 herostep();
12666 herostep();
12667 int32_t sidestep=0;
12668
12669 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12670 sidestep=1;
12671 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12672 sidestep=2;
12673
12674 if(sidestep==1) y++;
12675 else if(sidestep==2) y--;
12676 else x--;
12677
12678 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12679 {
12680 hopclk=0xFF;
12681 diveclk=0;
12682 SetSwim();
12683 }
12684 }
12685
12686 if(dir==right)
12687 {
12688 herostep();
12689 herostep();
12690
12691 int32_t sidestep=0;
12692
12693 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12694 sidestep=1;
12695 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12696 sidestep=2;
12697
12698 if(sidestep==1) y++;
12699 else if(sidestep==2) y--;
12700 else x++;
12701
12702 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12703 {
12704 hopclk=0xFF;
12705 diveclk=0;
12706 SetSwim();
12707 }
12708 }
12709 }
12710
12711 }
12712 else
12713 {
12714 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12715 {
12716 action=none; FFCore.setHeroAction(none);
12717 hopclk = 0;
12718 diveclk = 0;
12719
12720 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
12721 {
12722 // hopped in
12723 SetSwim();
12724 if (!IsSideSwim()) attackclk = charging = spins = 0;
12725 }
12726 }
12727 else
12728 {
12729 herostep();
12730 herostep();
12731
12732 if(++hero_count>(16*hero_animation_speed))
12733 hero_count=0;
12734
12735 int32_t xofs2 = x.getInt()&15;
12736 int32_t yofs2 = y.getInt()&15;
12737 int32_t s = 1 + (frame&1);
12738
12739 switch(dir)
12740 {
12741 case up:
12742 if(yofs2<3 || yofs2>13) --y;
12743 else y-=s;
12744
12745 break;
12746
12747 case down:
12748 if(yofs2<3 || yofs2>13) ++y;
12749 else y+=s;
12750
12751 break;
12752
12753 case left:
12754 if(xofs2<3 || xofs2>13) --x;
12755 else x-=s;
12756
12757 break;
12758
12759 case right:
12760 if(xofs2<3 || xofs2>13) ++x;
12761 else x+=s;
12762
12763 break;
12764 }
12765 }
12766 }
12767 }
12768 1 }
12769
12770 void HeroClass::do_rafting()
12771 {
12772
12773 if(toogam)
12774 {
12775 action=none; FFCore.setHeroAction(none);
12776 return;
12777 }
12778
12779 FFCore.setHeroAction(rafting);
12780
12781 do_lens();
12782
12783 herostep();
12784
12785 //Calculate rafting speed
12786 int32_t raft_item = current_item_id(itype_raft);
12787 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
12788 raft_step = vbound(raft_step, -8, 5);
12789 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
12790 if(raft_step < 0) raft_step = 1;
12791 int32_t step_inc = 1 << (raft_step - 1);
12792 // Fix position
12793 if(raft_step > 1)
12794 {
12795 if(x.getInt() & (step_inc-1))
12796 {
12797 x = x.getInt() & ~(step_inc-1);
12798 }
12799 if(y.getInt() & (step_inc-1))
12800 {
12801 y = y.getInt() & ~(step_inc-1);
12802 }
12803 }
12804 // Inc clock, check if we need to move this frame
12805 ++raftclk;
12806 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
12807
12808 if(!(x.getInt()&15) && !(y.getInt()&15))
12809 {
12810 // this sections handles switching to raft branches
12811 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
12812 {
12813 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12814 {
12815 dir = up;
12816 goto skip;
12817 }
12818
12819 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12820 {
12821 dir = down;
12822 goto skip;
12823 }
12824
12825 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12826 {
12827 dir = left;
12828 goto skip;
12829 }
12830
12831 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12832 {
12833 dir = right;
12834 goto skip;
12835 }
12836 }
12837 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
12838 {
12839 if(dir == left) dir = right;
12840 else if(dir == right) dir = left;
12841 else if(dir == up) dir = down;
12842 else if(dir == down) dir = up;
12843 }
12844
12845
12846 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
12847 {
12848 if(dir<left) //going up or down
12849 {
12850 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12851 dir=right;
12852 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12853 dir=left;
12854 else if(y>0 && y<160)
12855 {
12856 action=none; FFCore.setHeroAction(none);
12857 x = x.getInt();
12858 y = y.getInt();
12859 }
12860 }
12861 else //going left or right
12862 {
12863 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12864 dir=down;
12865 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12866 dir=up;
12867 else if(x>0 && x<240)
12868 {
12869 action=none; FFCore.setHeroAction(none);
12870 x = x.getInt();
12871 y = y.getInt();
12872 }
12873 }
12874 }
12875 }
12876
12877 skip:
12878
12879 switch(dir)
12880 {
12881 case up:
12882 if(x.getInt()&15)
12883 {
12884 if(x.getInt()&8)
12885 x++;
12886 else x--;
12887 }
12888 else y -= step_inc;
12889
12890 break;
12891
12892 case down:
12893 if(x.getInt()&15)
12894 {
12895 if(x.getInt()&8)
12896 x++;
12897 else x--;
12898 }
12899 else y += step_inc;
12900
12901 break;
12902
12903 case left:
12904 if(y.getInt()&15)
12905 {
12906 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12907 {
12908 if ((y.getInt() % 16) < 4) y--;
12909 else y++;
12910 }
12911 else
12912 {
12913 if(y.getInt()&8)
12914 y++;
12915 else y--;
12916 }
12917 }
12918 else x -= step_inc;
12919
12920 break;
12921
12922 case right:
12923 if(y.getInt()&15)
12924 {
12925 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12926 {
12927 if ((y.getInt() % 16) <= 4) y--;
12928 else y++;
12929 }
12930 else
12931 {
12932 if(y.getInt()&8)
12933 y++;
12934 else y--;
12935 }
12936 }
12937 else x += step_inc;
12938
12939 break;
12940 }
12941 }
12942
12943 bool HeroClass::try_hover()
12944 {
12945 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
12946 {
12947 int32_t itemid = current_item_id(itype_hoverboots);
12948 if(hoverclk < 0)
12949 hoverclk = -hoverclk;
12950 else
12951 {
12952 fall = fakefall = jumping = 0;
12953 if(itemsbuf[itemid].misc1)
12954 hoverclk = itemsbuf[itemid].misc1;
12955 else
12956 {
12957 hoverclk = 1;
12958 hoverflags |= HOV_INF;
12959 }
12960
12961
12962 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
12963 }
12964 if(itemsbuf[itemid].wpn)
12965 decorations.add(new dHover(x, y, dHOVER, 0));
12966 return true;
12967 }
12968 return false;
12969 }
12970
12971 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
12972 //Returns '-1' if not being pulled
12973 //Returns '-2' if should be falling in
12974 318099 int32_t HeroClass::check_pitslide(bool ignore_hover)
12975 {
12976 //Pitfall todo -Emily
12977 //Iron boots; can't fight slipping, 2px/frame
12978 //Scripted variables to read pull dir/clk (clk only for non-hero)
12979 //Implement falling for all sprite types (npc AI)
12980 // Fall/slipping tiles for enemies
12981 // Fall/slipping SFX for enemies
12982 // Fall SFX for items/weapons
12983 // Weapons/Misc sprite shared for falling items/weapons
12984 //Maybe slip SFX for Hero?
12985 // Weapons/Misc sprite override for falling sprite?
12986 //Update std.zh with relevant new stuff
12987
2/2
✓ Branch 0 taken 26966 times.
✓ Branch 1 taken 291133 times.
318099 if(can_pitfall(ignore_hover))
12988 {
12989
2/2
✓ Branch 0 taken 42645 times.
✓ Branch 1 taken 248488 times.
291133 bool can_diag = (diagonalMovement || get_bit(quest_rules,qr_DISABLE_4WAY_GRIDLOCK));
12990 291133 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
12991 291133 int32_t ispitbl = getpitfall(x,y+15);
12992 291133 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
12993 291133 int32_t ispitbr = getpitfall(x+15,y+15);
12994 291133 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
12995 291133 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
12996 291133 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
12997 291133 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
12998 291133 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
12999 291133 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13000 291133 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13001 291133 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13002 static const int32_t flag_pit_irresistable = (1<<24);
13003
1/5
✓ Branch 0 taken 291133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
291133 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13004 {
13005 case 4: return -2; //Fully over pit; fall in
13006 case 3:
13007 {
13008 if(ispitul && ispitur && ispitbl) //UL_3
13009 {
13010 if(ispitul_50)
13011 {
13012 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13013 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13014 }
13015 }
13016 else if(ispitul && ispitur && ispitbr) //UR_3
13017 {
13018 if(ispitur_50)
13019 {
13020 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13021 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13022 }
13023 }
13024 else if(ispitul && ispitbl && ispitbr) //BL_3
13025 {
13026 if(ispitbl_50)
13027 {
13028 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13029 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13030 }
13031 }
13032 else if(ispitbl && ispitur && ispitbr) //BR_3
13033 {
13034 if(ispitbr_50)
13035 {
13036 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13037 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13038 }
13039 }
13040 break;
13041 }
13042 case 2:
13043 {
13044 if(ispitul && ispitur) //Up
13045 {
13046 if(DrunkDown())
13047 {
13048 if(ispitul_75 && ispitur_75) //Straight up
13049 {
13050 return up | flag_pit_irresistable | (ispitul << 8);
13051 }
13052 else if(ispitul_75)
13053 {
13054 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13055 }
13056 else if(ispitur_75)
13057 {
13058 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13059 }
13060 else return -1;
13061 }
13062 else
13063 {
13064 if(ispitul_50 && ispitur_50) //Straight up
13065 {
13066 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13067 }
13068 else if(ispitul_50)
13069 {
13070 if(DrunkRight() && !ispitul_75) return -1;
13071 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13072 }
13073 else if(ispitur_50)
13074 {
13075 if(DrunkLeft() && !ispitur_75) return -1;
13076 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13077 }
13078 }
13079 }
13080 else if(ispitbl && ispitbr) //Down
13081 {
13082 if(DrunkUp())
13083 {
13084 if(ispitbl_75 && ispitbr_75) //Straight down
13085 {
13086 return down | flag_pit_irresistable | (ispitbl << 8);
13087 }
13088 else if(ispitbl_75)
13089 {
13090 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13091 }
13092 else if(ispitbr_75)
13093 {
13094 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13095 }
13096 else return -1;
13097 }
13098 else
13099 {
13100 if(ispitbl_50 && ispitbr_50) //Straight down
13101 {
13102 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13103 }
13104 else if(ispitbl_50)
13105 {
13106 if(DrunkRight() && !ispitbl_75) return -1;
13107 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13108 }
13109 else if(ispitbr_50)
13110 {
13111 if(DrunkLeft() && !ispitbr_75) return -1;
13112 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13113 }
13114 }
13115 }
13116 else if(ispitbl && ispitul) //Left
13117 {
13118 if(DrunkRight())
13119 {
13120 if(ispitul_75 && ispitbl_75) //Straight left
13121 {
13122 return left | flag_pit_irresistable | (ispitul << 8);
13123 }
13124 else if(ispitul_75)
13125 {
13126 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13127 }
13128 else if(ispitbl_75)
13129 {
13130 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13131 }
13132 else return -1;
13133 }
13134 else
13135 {
13136 if(ispitul_50 && ispitbl_50) //Straight left
13137 {
13138 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13139 }
13140 else if(ispitul_50)
13141 {
13142 if(DrunkDown() && !ispitul_75) return -1;
13143 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13144 }
13145 else if(ispitbl_50)
13146 {
13147 if(DrunkUp() && !ispitbl_75) return -1;
13148 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13149 }
13150 }
13151 }
13152 else if(ispitbr && ispitur) //Right
13153 {
13154 if(DrunkLeft())
13155 {
13156 if(ispitur_75 && ispitbr_75) //Straight right
13157 {
13158 return right | flag_pit_irresistable | (ispitur << 8);
13159 }
13160 else if(ispitur_75)
13161 {
13162 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13163 }
13164 else if(ispitbr_75)
13165 {
13166 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13167 }
13168 else return -1;
13169 }
13170 else
13171 {
13172 if(ispitur_50 && ispitbr_50) //Straight right
13173 {
13174 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13175 }
13176 else if(ispitur_50)
13177 {
13178 if(DrunkDown() && !ispitur_75) return -1;
13179 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13180 }
13181 else if(ispitbr_50)
13182 {
13183 if(DrunkUp() && !ispitbr_75) return -1;
13184 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13185 }
13186 }
13187 }
13188 break;
13189 }
13190 case 1:
13191 {
13192 if(ispitul && ispitul_50) //UL_1
13193 {
13194 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13195 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13196 }
13197 if(ispitur && ispitur_50) //UR_1
13198 {
13199 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13200 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13201 }
13202 if(ispitbl && ispitbl_50) //BL_1
13203 {
13204 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13205 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13206 }
13207 if(ispitbr && ispitbr_50) //BR_1
13208 {
13209 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13210 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13211 }
13212 break;
13213 }
13214 }
13215 291133 }
13216 318099 return -1;
13217 318099 }
13218
13219 67187 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13220 {
13221 67187 pitfall();
13222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67187 times.
67187 if(fallclk) return true;
13223 67187 int32_t val = check_pitslide();
13224 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67187 times.
67187 if(val == -1)
13226 {
13227 67187 pit_pulldir = -1;
13228 67187 pit_pullclk = 0;
13229 67187 return false;
13230 }
13231 int32_t dir = val&0xFF;
13232 int32_t cmbid = (val&0xFFFF00)>>8;
13233 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13234 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13235 {
13236 pit_pulldir = -1;
13237 pit_pullclk = 0;
13238 return false;
13239 }
13240 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13241 {
13242 pit_pulldir = -1;
13243 pit_pullclk = 0;
13244 return false;
13245 }
13246 pit_pulldir = dir;
13247 int32_t step = 1;
13248 if(sensitivity == 0)
13249 {
13250 step = 2;
13251 sensitivity = 1;
13252 }
13253 if(pit_pullclk++ % sensitivity) //No pull this frame
13254 return (val&0x100);
13255 for(; step > 0 && !fallclk; --step)
13256 {
13257 switch(dir)
13258 {
13259 case l_up: case l_down: case left:
13260 --x; break;
13261 case r_up: case r_down: case right:
13262 ++x; break;
13263 }
13264 switch(dir)
13265 {
13266 case l_up: case r_up: case up:
13267 --y; break;
13268 case l_down: case r_down: case down:
13269 ++y; break;
13270 }
13271 pitfall();
13272 }
13273 return fallclk || (val&0x100);
13274 67187 }
13275
13276 67187 void HeroClass::pitfall()
13277 {
13278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67187 times.
67187 if(fallclk)
13279 {
13280 drop_liftwpn();
13281 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13282 //Handle falling
13283 if(!--fallclk)
13284 {
13285 int32_t dmg = game->get_hp_per_heart()/4;
13286 bool dmg_perc = false;
13287 bool warp = false;
13288
13289 action=none; FFCore.setHeroAction(none);
13290 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13291 if(cmb)
13292 {
13293 dmg = cmb->attributes[0]/10000L;
13294 dmg_perc = cmb->usrflags&cflag3;
13295 warp = cmb->usrflags&cflag1;
13296 }
13297 if(dmg) //Damage
13298 {
13299 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13300 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13301 }
13302 if(warp) //Warp
13303 {
13304 sdir = dir;
13305 if(cmb->usrflags&cflag2) //Direct Warp
13306 {
13307 didpit=true;
13308 pitx=x;
13309 pity=y;
13310 }
13311 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13312 }
13313 else //Reset to screen entry
13314 {
13315 go_respawn_point();
13316 }
13317 }
13318 }
13319
2/2
✓ Branch 0 taken 6918 times.
✓ Branch 1 taken 60269 times.
67187 else if(can_pitfall())
13320 {
13321 60269 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13322 60269 bool ispitbl = ispitfall(x,y+15);
13323 60269 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13324 60269 bool ispitbr = ispitfall(x+15,y+15);
13325 60269 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13326
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 60269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
60269 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13327 {
13328 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13329 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13330 fallclk = PITFALL_FALL_FRAMES;
13331 fallCombo = pitctr;
13332 action=falling; FFCore.setHeroAction(falling);
13333 spins = 0;
13334 charging = 0;
13335 drop_liftwpn();
13336 }
13337 60269 }
13338 67187 }
13339
13340 75736 void HeroClass::movehero()
13341 {
13342
2/4
✓ Branch 0 taken 75736 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75736 times.
75736 if(lstunclock || is_conveyor_stunned) return;
13343 75736 int32_t xoff=x.getInt()&7;
13344 75736 int32_t yoff=y.getInt()&7;
13345
2/2
✓ Branch 0 taken 62339 times.
✓ Branch 1 taken 13397 times.
75736 if(NO_GRIDLOCK)
13346 {
13347 13397 xoff = 0;
13348 13397 yoff = 0;
13349 13397 }
13350 75736 int32_t push=pushing;
13351 75736 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13352 75736 pushing=0;
13353 75736 zfix temp_step(hero_newstep);
13354 75736 zfix temp_x(x);
13355 75736 zfix temp_y(y);
13356
13357 75736 int32_t flippers_id = current_item_id(itype_flippers);
13358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75736 times.
75736 if(diveclk>0)
13359 {
13360 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
13361 --diveclk;
13362 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
13363 {
13364 diveclk = itemsbuf[flippers_id].misc2;
13365 }
13366 }
13367
3/4
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 75460 times.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
75736 else if(action == swimming && DrunkrAbtn())
13368 {
13369 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13370 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13371
13372 if(global_diving==screen_diving)
13373 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13374 }
13375
13376
1/2
✓ Branch 0 taken 75736 times.
✗ Branch 1 not taken.
75736 if(action==rafting)
13377 {
13378 do_rafting();
13379
13380 if(action==rafting)
13381 {
13382 return;
13383 }
13384
13385
13386 set_respawn_point();
13387 trySideviewLadder();
13388 }
13389
13390 75736 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13391 75736 int32_t btnwpn = -1;
13392
13393 //&0xFFF removes the "bow & arrows" bitmask
13394 //The Quick Sword is allowed to interrupt attacks.
13395
3/4
✓ Branch 0 taken 75736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48810 times.
✓ Branch 3 taken 26926 times.
75736 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13396
8/8
✓ Branch 0 taken 67196 times.
✓ Branch 1 taken 8540 times.
✓ Branch 2 taken 67101 times.
✓ Branch 3 taken 95 times.
✓ Branch 4 taken 2502 times.
✓ Branch 5 taken 6133 times.
✓ Branch 6 taken 113 times.
✓ Branch 7 taken 8522 times.
75736 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13397 {
13398
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 66983 times.
67214 if(DrunkrBbtn())
13399 {
13400 231 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13401 231 dowpn = Bwpn&0xFFF;
13402 231 directWpn = directItemB;
13403 231 }
13404
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 66518 times.
66983 else if(DrunkrAbtn())
13405 {
13406 465 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13407 465 dowpn = Awpn&0xFFF;
13408 465 directWpn = directItemA;
13409 465 }
13410
3/4
✓ Branch 0 taken 1219 times.
✓ Branch 1 taken 65299 times.
✓ Branch 2 taken 1219 times.
✗ Branch 3 not taken.
66518 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13411 {
13412 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13413 dowpn = Xwpn&0xFFF;
13414 directWpn = directItemX;
13415 }
13416
3/4
✓ Branch 0 taken 1219 times.
✓ Branch 1 taken 65299 times.
✓ Branch 2 taken 1219 times.
✗ Branch 3 not taken.
66518 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13417 {
13418 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13419 dowpn = Ywpn&0xFFF;
13420 directWpn = directItemY;
13421 }
13422
13423
1/2
✓ Branch 0 taken 67214 times.
✗ Branch 1 not taken.
67214 if(directWpn > 255) directWpn = 0;
13424
13425 // The Quick Sword only allows repeated sword or wand swings.
13426
7/8
✓ Branch 0 taken 67101 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 67101 times.
✓ Branch 4 taken 105 times.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 67109 times.
67214 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13427 105 btnwpn=-1;
13428 67214 }
13429
13430
1/2
✓ Branch 0 taken 75736 times.
✗ Branch 1 not taken.
75736 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13431
9/12
✓ Branch 0 taken 74274 times.
✓ Branch 1 taken 1462 times.
✓ Branch 2 taken 49893 times.
✓ Branch 3 taken 24381 times.
✓ Branch 4 taken 49893 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49893 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 444 times.
✓ Branch 9 taken 49449 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 444 times.
75736 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13432 {
13433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 444 times.
444 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13434
2/6
✓ Branch 0 taken 444 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 444 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
444 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13435 {
13436
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 444 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
444 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13437 {
13438 paymagiccost(attackid,true);
13439 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13440 }
13441 444 SetAttack();
13442 444 attack=wSword;
13443
13444 444 attackclk=0;
13445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 444 times.
444 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13446
13447
2/10
✓ Branch 0 taken 444 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 444 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
444 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13448 {
13449 if(!checkmagiccost(dowpn))
13450 {
13451 if(QMisc.miscsfx[sfxERROR])
13452 sfx(QMisc.miscsfx[sfxERROR]);
13453 }
13454 else
13455 {
13456 //clear the item script stack for a new script
13457
13458 ri = &(itemScriptData[dowpn]);
13459 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13460 ri->Clear();
13461 //itemScriptData[(dowpn & 0xFFF)].Clear();
13462 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13463 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13464 item_doscript[dowpn] = 1;
13465 itemscriptInitialised[dowpn] = 0;
13466 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13467 did_scripta=true;
13468 }
13469 }
13470 444 }
13471 else
13472 {
13473 if(QMisc.miscsfx[sfxERROR])
13474 sfx(QMisc.miscsfx[sfxERROR]);
13475 }
13476 444 }
13477 else
13478 {
13479 75292 did_scripta=false;
13480 }
13481
13482
7/10
✓ Branch 0 taken 75460 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 75460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 75460 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 214 times.
✓ Branch 9 taken 75246 times.
75736 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13483 {
13484
4/4
✓ Branch 0 taken 13847 times.
✓ Branch 1 taken 61399 times.
✓ Branch 2 taken 13842 times.
✓ Branch 3 taken 5 times.
75246 if(DrunkUp() && canSideviewLadder())
13485 {
13486 5 setOnSideviewLadder(true);
13487 5 }
13488
3/4
✓ Branch 0 taken 9334 times.
✓ Branch 1 taken 65907 times.
✓ Branch 2 taken 9334 times.
✗ Branch 3 not taken.
75241 else if(DrunkDown() && canSideviewLadder(true))
13489 {
13490 y+=1;
13491 setOnSideviewLadder(true);
13492 }
13493 75246 }
13494
13495 75736 int32_t wx=x;
13496 75736 int32_t wy=y;
13497
5/6
✓ Branch 0 taken 52903 times.
✓ Branch 1 taken 22833 times.
✓ Branch 2 taken 219 times.
✓ Branch 3 taken 75517 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 219 times.
75736 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13498 {
13499
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219 if((xoff==0)||diagonalMovement)
13500 {
13501
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 180 times.
219 if(DrunkUp()) dir=up;
13502
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if(DrunkDown()) dir=down;
13503 219 }
13504
13505
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219 if((yoff==0)||diagonalMovement)
13506 {
13507
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 23 times.
219 if(DrunkLeft()) dir=left;
13508
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 29 times.
219 if(DrunkRight()) dir=right;
13509 219 }
13510 219 }
13511
13512
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17587 times.
✓ Branch 2 taken 11102 times.
✓ Branch 3 taken 19892 times.
✓ Branch 4 taken 27155 times.
75736 switch(dir)
13513 {
13514 case up:
13515 17587 wy-=16;
13516 17587 break;
13517
13518 case down:
13519 11102 wy+=16;
13520 11102 break;
13521
13522 case left:
13523 19892 wx-=16;
13524 19892 break;
13525
13526 case right:
13527 27155 wx+=16;
13528 27155 break;
13529 }
13530
13531 75736 do_lens();
13532
13533 75736 WalkflagInfo info;
13534
13535 75736 bool no_jinx = true;
13536
7/8
✓ Branch 0 taken 74274 times.
✓ Branch 1 taken 1462 times.
✓ Branch 2 taken 247 times.
✓ Branch 3 taken 74027 times.
✓ Branch 4 taken 247 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✓ Branch 7 taken 232 times.
75736 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13537 {
13538 232 bool paidmagic = false;
13539
1/8
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
232 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13540 {
13541 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13542 no_jinx = checkitem_jinx(attackid);
13543 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13544 {
13545 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13546 paymagiccost(attackid,true);
13547 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13548 }
13549 SetAttack();
13550 attack=wWand;
13551 attackclk=0;
13552 }
13553 else
13554 {
13555 if(QMisc.miscsfx[sfxERROR])
13556 sfx(QMisc.miscsfx[sfxERROR]);
13557 }
13558 }
13559
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 232 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
232 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13560 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13561 {
13562 no_jinx = checkitem_jinx(dowpn);
13563 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13564 {
13565 if(QMisc.miscsfx[sfxERROR])
13566 sfx(QMisc.miscsfx[sfxERROR]);
13567 }
13568 else
13569 {
13570 paymagiccost(dowpn);
13571 paidmagic = true;
13572 SetAttack();
13573 attack=wHammer;
13574 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13575 attackclk=0;
13576 }
13577 }
13578
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 232 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
232 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13579 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13580 {
13581 //checkbunny handled where magic cost is paid
13582 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13583 no_jinx = checkitem_jinx(attackid);
13584 if(no_jinx)
13585 {
13586 SetAttack();
13587 attack=wFire;
13588 attackclk=0;
13589 }
13590 }
13591
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 232 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
232 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13592 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13593 {
13594 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13595 no_jinx = checkitem_jinx(attackid);
13596 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13597 {
13598 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13599 paymagiccost(attackid,true);
13600 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13601 }
13602 SetAttack();
13603 attack=wCByrna;
13604 attackclk=0;
13605 }
13606 else
13607 {
13608 if(QMisc.miscsfx[sfxERROR])
13609 sfx(QMisc.miscsfx[sfxERROR]);
13610 }
13611 }
13612
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 232 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
232 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
13613 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
13614 {
13615 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
13616 no_jinx = checkitem_jinx(attackid);
13617 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
13618 {
13619 paymagiccost(attackid);
13620 SetAttack();
13621 attack = wBugNet;
13622 attackclk = 0;
13623 sfx(itemsbuf[attackid].usesound);
13624 }
13625 else
13626 {
13627 if(QMisc.miscsfx[sfxERROR])
13628 sfx(QMisc.miscsfx[sfxERROR]);
13629 }
13630 }
13631 else
13632 {
13633
1/2
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
232 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
13634 232 no_jinx = checkitem_jinx(itmid);
13635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 232 times.
232 if(no_jinx)
13636 {
13637 232 paidmagic = startwpn(itmid);
13638
13639
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 71 times.
232 if(paidmagic)
13640 {
13641
5/10
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 161 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 161 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 161 times.
161 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
13642 {
13643 ;
13644 }
13645 else
13646 {
13647 161 SetAttack();
13648 161 attackclk=0;
13649 161 attack=none;
13650
13651
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 157 times.
161 if(btnwpn==itype_brang)
13652 {
13653 157 attack=wBrang;
13654 157 }
13655 }
13656 161 }
13657 else
13658 {
13659 // Weapon not started: directWpn should be reset to prev. value.
13660 71 directWpn = olddirectwpn;
13661 }
13662 232 }
13663 }
13664
13665
3/12
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 232 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 232 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
232 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13666 {
13667 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
13668 {
13669 if(QMisc.miscsfx[sfxERROR])
13670 sfx(QMisc.miscsfx[sfxERROR]);
13671 }
13672 else
13673 {
13674 // Only charge for magic if item's magic cost wasn't already charged
13675 // for the item's main use.
13676 if(!paidmagic && attack!=wWand)
13677 paymagiccost(dowpn);
13678 //clear the item script stack for a new script
13679 //itemScriptData[(dowpn & 0xFFF)].Clear();
13680 ri = &(itemScriptData[dowpn]);
13681 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13682 ri->Clear();
13683 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13684 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13685 item_doscript[dowpn] = 1;
13686 itemscriptInitialised[dowpn] = 0;
13687 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13688 did_scriptb=true;
13689 }
13690 }
13691
13692
6/12
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 232 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 232 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 232 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 232 times.
232 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
13693 {
13694 return;
13695 }
13696
1/2
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
232 if(!no_jinx)
13697 did_scriptb = false;
13698 232 }
13699 else
13700 {
13701 75504 did_scriptb=false;
13702 }
13703
13704
5/6
✓ Branch 0 taken 67204 times.
✓ Branch 1 taken 8532 times.
✓ Branch 2 taken 66504 times.
✓ Branch 3 taken 700 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 66504 times.
75736 if(attackclk || action==attacking || action==sideswimattacking)
13705 {
13706
13707
4/8
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 8532 times.
✓ Branch 2 taken 700 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 700 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9232 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13708 {
13709 if((xoff==0)||diagonalMovement)
13710 {
13711 if(DrunkUp()) dir=up;
13712 if(DrunkDown()) dir=down;
13713 }
13714
13715 if((yoff==0)||diagonalMovement)
13716 {
13717 if(DrunkLeft()) dir=left;
13718 if(DrunkRight()) dir=right;
13719 }
13720 }
13721
13722 9232 bool attacked = doattack();
13723
13724 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
13725
8/12
✓ Branch 0 taken 9232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6435 times.
✓ Branch 3 taken 2797 times.
✓ Branch 4 taken 1227 times.
✓ Branch 5 taken 5208 times.
✓ Branch 6 taken 1227 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1227 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1227 times.
9232 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
13726 {
13727
3/4
✓ Branch 0 taken 644 times.
✓ Branch 1 taken 583 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 644 times.
1227 if((xoff==0)||diagonalMovement)
13728 {
13729
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 78 times.
583 if(DrunkUp()) dir=up;
13730
13731
2/2
✓ Branch 0 taken 530 times.
✓ Branch 1 taken 53 times.
583 if(DrunkDown()) dir=down;
13732 583 }
13733
13734
3/4
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 940 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 287 times.
1227 if((yoff==0)||diagonalMovement)
13735 {
13736
2/2
✓ Branch 0 taken 806 times.
✓ Branch 1 taken 134 times.
940 if(DrunkLeft()) dir=left;
13737
13738
2/2
✓ Branch 0 taken 784 times.
✓ Branch 1 taken 156 times.
940 if(DrunkRight()) dir=right;
13739 940 }
13740 1227 }
13741
13742
6/10
✓ Branch 0 taken 8549 times.
✓ Branch 1 taken 683 times.
✓ Branch 2 taken 8549 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8549 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8549 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 8549 times.
9232 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
13743 {
13744 8549 return;
13745 }
13746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 683 times.
683 else if(!(attacked))
13747 {
13748 // Spin attack - change direction
13749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 683 times.
683 if(spins>1)
13750 {
13751 spins--;
13752
13753 if(spins%5==0)
13754 sfx(itemsbuf[current_item_id(spins >5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
13755
13756 attackclk=1;
13757
13758 switch(dir)
13759 {
13760 case up:
13761 dir=left;
13762 break;
13763
13764 case right:
13765 dir=up;
13766 break;
13767
13768 case down:
13769 dir=right;
13770 break;
13771
13772 case left:
13773 dir=down;
13774 break;
13775 }
13776
13777 return;
13778 }
13779 else
13780 {
13781 683 spins=0;
13782 }
13783
13784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 683 times.
683 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
13785 683 else {action=none; FFCore.setHeroAction(none);}
13786 683 attackclk=0;
13787 683 charging=0;
13788 683 }
13789 683 }
13790
13791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67187 times.
67187 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
13792 return;
13793
13794
2/2
✓ Branch 0 taken 23766 times.
✓ Branch 1 taken 43421 times.
67187 if(action==walking) //still walking
13795 {
13796
9/10
✓ Branch 0 taken 31819 times.
✓ Branch 1 taken 11602 times.
✓ Branch 2 taken 24348 times.
✓ Branch 3 taken 7471 times.
✓ Branch 4 taken 13480 times.
✓ Branch 5 taken 10868 times.
✓ Branch 6 taken 449 times.
✓ Branch 7 taken 13031 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 449 times.
43421 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
13797 {
13798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449 times.
449 if(attackclk>0) SetAttack();
13799 449 else {action = none; FFCore.setHeroAction(none);}
13800 449 hero_count=-1;
13801 449 return;
13802 }
13803
13804 42972 autostep=false;
13805
13806
3/4
✓ Branch 0 taken 36297 times.
✓ Branch 1 taken 6675 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36297 times.
42972 if(!(diagonalMovement || NO_GRIDLOCK))
13807 {
13808
2/4
✓ Branch 0 taken 36297 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36297 times.
36297 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
13809 {
13810 if(dir==up&&yoff)
13811 {
13812 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
13813 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
13814 execute(info);
13815
13816 if(!info.isUnwalkable())
13817 {
13818 move(up);
13819 }
13820 else
13821 {
13822 action=none; FFCore.setHeroAction(none);
13823 }
13824
13825 return;
13826 }
13827
13828 if(dir==down&&yoff)
13829 {
13830 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
13831 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
13832 execute(info);
13833
13834 if(!info.isUnwalkable())
13835 {
13836 move(down);
13837 }
13838 else
13839 {
13840 action=none; FFCore.setHeroAction(none);
13841 }
13842
13843 return;
13844 }
13845
13846 if(dir==left&&xoff)
13847 {
13848 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
13849 execute(info);
13850
13851 if(!info.isUnwalkable())
13852 {
13853 move(left);
13854 }
13855 else
13856 {
13857 action=none; FFCore.setHeroAction(none);
13858 }
13859
13860 return;
13861 }
13862
13863 if(dir==right&&xoff)
13864 {
13865 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
13866 execute(info);
13867
13868 if(!info.isUnwalkable())
13869 {
13870 move(right);
13871 }
13872 else
13873 {
13874 action=none; FFCore.setHeroAction(none);
13875 }
13876
13877 return;
13878 }
13879 }
13880 else
13881 {
13882
4/4
✓ Branch 0 taken 8910 times.
✓ Branch 1 taken 27387 times.
✓ Branch 2 taken 1471 times.
✓ Branch 3 taken 7439 times.
36297 if(dir==up&&yoff)
13883 {
13884 7439 while(true)
13885 {
13886 7439 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
13887 7439 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
13888 7439 execute(info);
13889
13890
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 7429 times.
7439 if(!info.isUnwalkable())
13891 {
13892 7429 hero_newstep = temp_step;
13893 7429 x = temp_x;
13894 7429 y = temp_y;
13895 7429 move(up);
13896 7429 return;
13897 }
13898 //Could not move, try moving less
13899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(temp_y != int32_t(temp_y))
13900 {
13901 temp_y = floor((double)temp_y);
13902 continue;
13903 }
13904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 else if(temp_step > 1)
13905 {
13906 if(temp_step != int32_t(temp_step)) //floor
13907 temp_step = floor((double)temp_step);
13908 else --temp_step;
13909 continue;
13910 }
13911 else //Can't move less, stop moving
13912 {
13913 10 action=none; FFCore.setHeroAction(none);
13914 }
13915 10 return;
13916 }
13917 }
13918
13919
4/4
✓ Branch 0 taken 5498 times.
✓ Branch 1 taken 23360 times.
✓ Branch 2 taken 935 times.
✓ Branch 3 taken 4563 times.
28858 if(dir==down&&yoff)
13920 {
13921 4563 while(true)
13922 {
13923 4566 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
13924 4566 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
13925 4566 execute(info);
13926
13927
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4563 times.
4566 if(!info.isUnwalkable())
13928 {
13929 4563 hero_newstep = temp_step;
13930 4563 x = temp_x;
13931 4563 y = temp_y;
13932 4563 move(down);
13933 4563 return;
13934 }
13935 //Could not move, try moving less
13936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(temp_y != int32_t(temp_y))
13937 {
13938 temp_y = floor((double)temp_y);
13939 continue;
13940 }
13941
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if(temp_step > 1)
13942 {
13943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(temp_step != int32_t(temp_step)) //floor
13944 3 temp_step = floor((double)temp_step);
13945 else --temp_step;
13946 3 continue;
13947 }
13948 else //Can't move less, stop moving
13949 {
13950 action=none; FFCore.setHeroAction(none);
13951 }
13952 return;
13953 }
13954 }
13955
13956
4/4
✓ Branch 0 taken 10167 times.
✓ Branch 1 taken 14128 times.
✓ Branch 2 taken 1710 times.
✓ Branch 3 taken 8457 times.
24295 if(dir==left&&xoff)
13957 {
13958 8457 while(true)
13959 {
13960 8457 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
13961 8457 execute(info);
13962
13963
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 8447 times.
8457 if(!info.isUnwalkable())
13964 {
13965 8447 hero_newstep = temp_step;
13966 8447 x = temp_x;
13967 8447 y = temp_y;
13968 8447 move(left);
13969 8447 return;
13970 }
13971 //Could not move, try moving less
13972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(temp_x != int32_t(temp_x))
13973 {
13974 temp_x = floor((double)temp_x);
13975 continue;
13976 }
13977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 else if(temp_step > 1)
13978 {
13979 if(temp_step != int32_t(temp_step)) //floor
13980 temp_step = floor((double)temp_step);
13981 else --temp_step;
13982 continue;
13983 }
13984 else //Can't move less, stop moving
13985 {
13986 10 action=none; FFCore.setHeroAction(none);
13987 }
13988 10 return;
13989 }
13990 }
13991
13992
4/4
✓ Branch 0 taken 11722 times.
✓ Branch 1 taken 4116 times.
✓ Branch 2 taken 1957 times.
✓ Branch 3 taken 9765 times.
15838 if(dir==right&&xoff)
13993 {
13994 9765 while(true)
13995 {
13996 9771 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
13997 9771 execute(info);
13998
13999
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 9760 times.
9771 if(!info.isUnwalkable())
14000 {
14001 9760 hero_newstep = temp_step;
14002 9760 x = temp_x;
14003 9760 y = temp_y;
14004 9760 move(right);
14005 9760 return;
14006 }
14007 //Could not move, try moving less
14008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(temp_x != int32_t(temp_x))
14009 {
14010 temp_x = floor((double)temp_x);
14011 continue;
14012 }
14013
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 else if(temp_step > 1)
14014 {
14015
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(temp_step != int32_t(temp_step)) //floor
14016 6 temp_step = floor((double)temp_step);
14017 else --temp_step;
14018 6 continue;
14019 }
14020 else //Can't move less, stop moving
14021 {
14022 5 action=none; FFCore.setHeroAction(none);
14023 }
14024 5 return;
14025 }
14026 }
14027 }
14028 6073 }
14029
14030 12748 } // endif (action==walking)
14031
14032
14/24
✓ Branch 0 taken 36238 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 36238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36238 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36238 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36238 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 36238 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 36238 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 36238 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 36238 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 36238 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 36238 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1938 times.
✓ Branch 23 taken 34300 times.
36514 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
14033 {
14034 34300 action=none; FFCore.setHeroAction(none);
14035 34300 }
14036
14037
2/2
✓ Branch 0 taken 14302 times.
✓ Branch 1 taken 22212 times.
36514 if(diagonalMovement)
14038 {
14039
5/5
✓ Branch 0 taken 4916 times.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1875 times.
✓ Branch 3 taken 2733 times.
✓ Branch 4 taken 3975 times.
14302 switch(holddir)
14040 {
14041 case up:
14042
2/2
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 34 times.
803 if(!Up())
14043 {
14044 34 holddir=-1;
14045 34 }
14046
14047 803 break;
14048
14049 case down:
14050
2/2
✓ Branch 0 taken 1837 times.
✓ Branch 1 taken 38 times.
1875 if(!Down())
14051 {
14052 38 holddir=-1;
14053 38 }
14054
14055 1875 break;
14056
14057 case left:
14058
2/2
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 97 times.
2733 if(!Left())
14059 {
14060 97 holddir=-1;
14061 97 }
14062
14063 2733 break;
14064
14065 case right:
14066
2/2
✓ Branch 0 taken 3868 times.
✓ Branch 1 taken 107 times.
3975 if(!Right())
14067 {
14068 107 holddir=-1;
14069 107 }
14070
14071 3975 break;
14072
14073 default:
14074 4916 break;
14075 } //end switch
14076
14077
3/4
✓ Branch 0 taken 1591 times.
✓ Branch 1 taken 12711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1591 times.
14302 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
14078 {
14079 12711 walkable = false;
14080
6/6
✓ Branch 0 taken 1683 times.
✓ Branch 1 taken 11028 times.
✓ Branch 2 taken 1657 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 954 times.
✓ Branch 5 taken 703 times.
12711 if(DrunkUp()&&(holddir==-1||holddir==up))
14081 {
14082
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 729 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
729 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14083 {
14084 }
14085 else
14086 {
14087
4/10
✓ Branch 0 taken 729 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 729 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 729 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 729 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
729 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14088 {
14089 729 dir=up;
14090 729 }
14091
14092 729 holddir=up;
14093
14094
4/4
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 244 times.
729 if(DrunkRight()&&shiftdir!=left)
14095 {
14096 244 shiftdir=right;
14097
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
244 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14098
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
244 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14099 244 }
14100
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 391 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
485 else if(DrunkLeft()&&shiftdir!=right)
14101 {
14102 94 shiftdir=left;
14103
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
94 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14104
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14105 94 }
14106 else
14107 {
14108 391 shiftdir=-1;
14109 }
14110
14111 //walkable if Ladder can be placed or is already placed vertically
14112
9/20
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 535 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 55 times.
✓ Branch 13 taken 139 times.
✓ Branch 14 taken 55 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 55 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 55 times.
729 if(isSideViewHero() && !toogam && (!get_bit(quest_rules, qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14113 {
14114 55 walkable=false;
14115 55 }
14116 else
14117 {
14118 674 do
14119 {
14120 880 info = walkflag(x,(bigHitbox?0:8)+(y-hero_newstep),2,up);
14121
14122 880 info = info || walkflag(x+15,(bigHitbox?0:8)+(y-hero_newstep),1,up);
14123 880 info = info || walkflagMBlock(x+15, (bigHitbox?0:8)+(y-hero_newstep));
14124
14125 880 execute(info);
14126
14127
2/2
✓ Branch 0 taken 411 times.
✓ Branch 1 taken 469 times.
880 if(info.isUnwalkable())
14128 {
14129
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 410 times.
411 if(y != y.getInt())
14130 {
14131 1 y.doRound();
14132 1 }
14133
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 205 times.
410 else if(hero_newstep > 1)
14134 {
14135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(hero_newstep != int32_t(hero_newstep)) //floor
14136 205 hero_newstep = floor((double)hero_newstep);
14137 else --hero_newstep;
14138 205 }
14139 else
14140 205 break;
14141 206 }
14142 469 else walkable = true;
14143
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 469 times.
675 }
14144 675 while(!walkable);
14145 }
14146
14147 729 int32_t s=shiftdir;
14148
14149
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 729 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
729 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14150 {
14151 shiftdir=-1;
14152 }
14153 else
14154 {
14155
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 635 times.
729 if(s==left)
14156 {
14157 94 do
14158 {
14159 108 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14160
14161 108 execute(info);
14162
14163
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 80 times.
108 if(info.isUnwalkable())
14164 {
14165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(x != x.getInt())
14166 {
14167 x.doRound();
14168 }
14169
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 else if(hero_newstep_diag > 1)
14170 {
14171
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14172 14 hero_newstep_diag.doFloor();
14173 else --hero_newstep_diag;
14174 14 }
14175 else
14176 14 shiftdir = -1;
14177 28 }
14178
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 39 times.
80 else if(walkable)
14179 {
14180 41 do
14181 {
14182 42 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14183 42 execute(info);
14184
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 40 times.
42 if(info.isUnwalkable())
14185 {
14186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(x != x.getInt())
14187 {
14188 x.doRound();
14189 }
14190
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(hero_newstep_diag > 1)
14191 {
14192
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14193 1 hero_newstep_diag.doFloor();
14194 else --hero_newstep_diag;
14195 1 }
14196 else
14197 1 shiftdir = -1;
14198 2 }
14199 40 else break;
14200
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 }
14201 2 while(shiftdir != -1);
14202 41 break;
14203 }
14204 39 else break;
14205
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 }
14206 28 while(shiftdir != -1);
14207 94 }
14208
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 244 times.
635 else if(s==right)
14209 {
14210 244 do
14211 {
14212 262 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14213
14214 262 execute(info);
14215
14216
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 227 times.
262 if(info.isUnwalkable())
14217 {
14218
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
35 if(x != x.getInt())
14219 {
14220 1 x.doRound();
14221 1 }
14222
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 17 times.
34 else if(hero_newstep_diag > 1)
14223 {
14224
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14225 17 hero_newstep_diag.doFloor();
14226 else --hero_newstep_diag;
14227 17 }
14228 else
14229 17 shiftdir = -1;
14230 35 }
14231
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 109 times.
227 else if(walkable)
14232 {
14233 118 do
14234 {
14235 118 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14236 118 execute(info);
14237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(info.isUnwalkable())
14238 {
14239 if(x != x.getInt())
14240 {
14241 x.doRound();
14242 }
14243 else if(hero_newstep_diag > 1)
14244 {
14245 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14246 hero_newstep_diag.doFloor();
14247 else --hero_newstep_diag;
14248 }
14249 else
14250 shiftdir = -1;
14251 }
14252 118 else break;
14253 }
14254 while(shiftdir != -1);
14255 118 break;
14256 }
14257 109 else break;
14258
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 17 times.
35 }
14259 35 while(shiftdir != -1);
14260 244 }
14261 }
14262
14263 729 move(up);
14264 729 shiftdir=s;
14265
14266
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 260 times.
729 if(!walkable)
14267 {
14268
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 112 times.
260 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14269 {
14270 112 x = x.getInt();
14271 112 y = y.getInt();
14272
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 112 times.
165 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14273
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 52 times.
53 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14274
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
52 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14275 {
14276 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14277 sprite::move((zfix)-1,(zfix)0);
14278 }
14279 else
14280 {
14281
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 59 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 106 times.
171 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14282
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 6 times.
59 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14283
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14284 {
14285
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
6 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14286 6 sprite::move((zfix)1,(zfix)0);
14287 6 }
14288 else
14289 {
14290 106 pushing=push+1;
14291 }
14292 }
14293 112 }
14294 else
14295 {
14296 148 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14297 }
14298 260 }
14299
14300 729 return;
14301 }
14302 }
14303
14304
6/6
✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 9797 times.
✓ Branch 2 taken 2153 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 1642 times.
✓ Branch 5 taken 511 times.
11982 if(DrunkDown()&&(holddir==-1||holddir==down))
14305 {
14306
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1674 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1674 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14307 {
14308 }
14309 else
14310 {
14311
4/10
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1674 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1674 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1674 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1674 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14312 {
14313 1674 dir=down;
14314 1674 }
14315
14316 1674 holddir=down;
14317
14318
3/4
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 1103 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 571 times.
1674 if(DrunkRight()&&shiftdir!=left)
14319 {
14320 571 shiftdir=right;
14321
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 571 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
571 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14322
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 571 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
571 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14323 571 }
14324
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 718 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1103 else if(DrunkLeft()&&shiftdir!=right)
14325 {
14326 385 shiftdir=left;
14327
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
385 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14328
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
385 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14329 385 }
14330 else
14331 {
14332 718 shiftdir=-1;
14333 }
14334
14335 //bool walkable;
14336
7/12
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 660 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 660 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 660 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 660 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 660 times.
1674 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14337 {
14338 660 walkable=false;
14339 660 }
14340 else
14341 {
14342 1014 do
14343 {
14344 1389 info = walkflag(x,15+(y+hero_newstep),2,down);
14345
14346
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 245 times.
1389 if(x.getFloor() & 7)
14347 1144 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14348 else
14349 245 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14350
14351 1389 execute(info);
14352
14353
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 650 times.
1389 if(info.isUnwalkable())
14354 {
14355
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 731 times.
739 if(y != y.getInt())
14356 {
14357 8 y.doRound();
14358 8 }
14359
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 364 times.
731 else if(hero_newstep > 1)
14360 {
14361
1/2
✓ Branch 0 taken 367 times.
✗ Branch 1 not taken.
367 if(hero_newstep != int32_t(hero_newstep)) //floor
14362 367 hero_newstep = floor((double)hero_newstep);
14363 else --hero_newstep;
14364 367 }
14365 else
14366 364 break;
14367 375 }
14368 650 else walkable = true;
14369
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 650 times.
1025 }
14370 1025 while(!walkable);
14371 }
14372
14373 1674 int32_t s=shiftdir;
14374
14375
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1674 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1674 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14376 {
14377 shiftdir=-1;
14378 }
14379 else
14380 {
14381
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1289 times.
1674 if(s==left)
14382 {
14383 385 do
14384 {
14385 413 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14386
14387 413 execute(info);
14388
14389
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 359 times.
413 if(info.isUnwalkable())
14390 {
14391
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 52 times.
54 if(x != x.getInt())
14392 {
14393 2 x.doRound();
14394 2 }
14395
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
52 else if(hero_newstep_diag > 1)
14396 {
14397
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14398 26 hero_newstep_diag.doFloor();
14399 else --hero_newstep_diag;
14400 26 }
14401 else
14402 26 shiftdir = -1;
14403 54 }
14404
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 232 times.
359 else if(walkable)
14405 {
14406 127 do
14407 {
14408 127 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14409 127 execute(info);
14410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(info.isUnwalkable())
14411 {
14412 if(x != x.getInt())
14413 {
14414 x.doRound();
14415 }
14416 else if(hero_newstep_diag > 1)
14417 {
14418 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14419 hero_newstep_diag.doFloor();
14420 else --hero_newstep_diag;
14421 }
14422 else
14423 shiftdir = -1;
14424 }
14425 127 else break;
14426 }
14427 while(shiftdir != -1);
14428 127 break;
14429 }
14430 232 else break;
14431
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 26 times.
54 }
14432 54 while(shiftdir != -1);
14433 385 }
14434
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 571 times.
1289 else if(s==right)
14435 {
14436 571 do
14437 {
14438 585 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14439
14440 585 execute(info);
14441
14442
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 558 times.
585 if(info.isUnwalkable())
14443 {
14444
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26 times.
27 if(x != x.getInt())
14445 {
14446 1 x.doRound();
14447 1 }
14448
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 else if(hero_newstep_diag > 1)
14449 {
14450
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14451 13 hero_newstep_diag.doFloor();
14452 else --hero_newstep_diag;
14453 13 }
14454 else
14455 13 shiftdir = -1;
14456 27 }
14457
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 383 times.
558 else if(walkable)
14458 {
14459 175 do
14460 {
14461 177 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14462 177 execute(info);
14463
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 174 times.
177 if(info.isUnwalkable())
14464 {
14465
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(x != x.getInt())
14466 {
14467 1 x.doRound();
14468 1 }
14469
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(hero_newstep_diag > 1)
14470 {
14471
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14472 1 hero_newstep_diag.doFloor();
14473 else --hero_newstep_diag;
14474 1 }
14475 else
14476 1 shiftdir = -1;
14477 3 }
14478 174 else break;
14479
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 }
14480 3 while(shiftdir != -1);
14481 175 break;
14482 }
14483 383 else break;
14484
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 13 times.
27 }
14485 27 while(shiftdir != -1);
14486 571 }
14487 }
14488
14489 1674 move(down);
14490 1674 shiftdir=s;
14491
14492
2/2
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 1024 times.
1674 if(!walkable)
14493 {
14494
2/2
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 407 times.
1024 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14495 {
14496 407 x = x.getInt();
14497 407 y = y.getInt();
14498
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 407 times.
✓ Branch 2 taken 407 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✓ Branch 5 taken 319 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 391 times.
726 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14499
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 309 times.
319 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14500
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
✓ Branch 2 taken 309 times.
✗ Branch 3 not taken.
309 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14501 {
14502
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16 times.
16 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
14503 16 sprite::move((zfix)-1,(zfix)0);
14504 16 }
14505
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 391 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 303 times.
✓ Branch 5 taken 88 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 386 times.
479 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14506
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 5 times.
88 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14507
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14508 {
14509
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
5 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
14510 5 sprite::move((zfix)1,(zfix)0);
14511 5 }
14512 else
14513 {
14514 386 pushing=push+1;
14515 }
14516 407 }
14517 else
14518 {
14519 617 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14520 }
14521 1024 }
14522
14523 1674 return;
14524 }
14525 }
14526
14527
6/6
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 7967 times.
✓ Branch 2 taken 2256 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 2254 times.
✓ Branch 5 taken 2 times.
10308 if(DrunkLeft()&&(holddir==-1||holddir==left))
14528 {
14529
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2339 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14530 {
14531 }
14532 else
14533 {
14534
3/6
✓ Branch 0 taken 2339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2339 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2339 times.
2339 if(charging==0 && spins==0 && action != sideswimattacking)
14535 {
14536 2339 dir=left;
14537 2339 }
14538 2339 sideswimdir = left;
14539
14540 2339 holddir=left;
14541
14542
3/4
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 1992 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 347 times.
2339 if(DrunkUp()&&shiftdir!=down)
14543 {
14544 347 shiftdir=up;
14545 347 }
14546
3/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 1796 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
1992 else if(DrunkDown()&&shiftdir!=up)
14547 {
14548 196 shiftdir=down;
14549 196 }
14550 else
14551 {
14552 1796 shiftdir=-1;
14553 }
14554
14555 2339 do
14556 {
14557 2645 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14558
14559 2645 info = info || walkflag(x-hero_newstep,y+15,1,left);
14560
14561 2645 execute(info);
14562
14563
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 2104 times.
2645 if(info.isUnwalkable())
14564 {
14565
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 470 times.
541 if(x != x.getInt())
14566 {
14567 71 x.doRound();
14568 71 }
14569
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 235 times.
470 else if(hero_newstep > 1)
14570 {
14571
1/2
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
235 if(hero_newstep != int32_t(hero_newstep)) //floor
14572 235 hero_newstep = floor((double)hero_newstep);
14573 else --hero_newstep;
14574 235 }
14575 else
14576 235 break;
14577 306 }
14578 2104 else walkable = true;
14579
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 2104 times.
2410 }
14580 2410 while(!walkable);
14581
14582 2339 int32_t s=shiftdir;
14583
14584
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 2339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1405 times.
✓ Branch 7 taken 934 times.
✓ Branch 8 taken 1382 times.
✓ Branch 9 taken 23 times.
✓ Branch 10 taken 1382 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1382 times.
✗ Branch 13 not taken.
2339 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14585 {
14586 1382 shiftdir=-1;
14587 1382 }
14588 else
14589 {
14590
2/2
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 243 times.
957 if(s==up)
14591 {
14592 243 do
14593 {
14594 317 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14595
14596 317 execute(info);
14597
14598
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 170 times.
317 if(info.isUnwalkable())
14599 {
14600
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 146 times.
147 if(y != y.getInt())
14601 {
14602 1 y.doRound();
14603 1 }
14604
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 73 times.
146 else if(hero_newstep_diag > 1)
14605 {
14606
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14607 73 hero_newstep_diag.doFloor();
14608 else --hero_newstep_diag;
14609 73 }
14610 else
14611 73 shiftdir = -1;
14612 147 }
14613
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 54 times.
170 else if(walkable)
14614 {
14615 116 do
14616 {
14617 116 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14618 116 execute(info);
14619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(info.isUnwalkable())
14620 {
14621 if(y != y.getInt())
14622 {
14623 y.doRound();
14624 }
14625 else if(hero_newstep_diag > 1)
14626 {
14627 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14628 hero_newstep_diag.doFloor();
14629 else --hero_newstep_diag;
14630 }
14631 else
14632 shiftdir = -1;
14633 }
14634 116 else break;
14635 }
14636 while(shiftdir != -1);
14637 116 break;
14638 }
14639 54 else break;
14640
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 73 times.
147 }
14641 147 while(shiftdir != -1);
14642 243 }
14643
2/2
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 135 times.
714 else if(s==down)
14644 {
14645 135 do
14646 {
14647 184 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14648
14649 184 execute(info);
14650
14651
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 90 times.
184 if(info.isUnwalkable())
14652 {
14653
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 90 times.
94 if(y != y.getInt())
14654 {
14655 4 y.doRound();
14656 4 }
14657
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 45 times.
90 else if(hero_newstep_diag > 1)
14658 {
14659
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14660 45 hero_newstep_diag.doFloor();
14661 else --hero_newstep_diag;
14662 45 }
14663 else
14664 45 shiftdir = -1;
14665 94 }
14666
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 21 times.
90 else if(walkable)
14667 {
14668 69 do
14669 {
14670 69 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
14671 69 execute(info);
14672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(info.isUnwalkable())
14673 {
14674 if(y != y.getInt())
14675 {
14676 y.doRound();
14677 }
14678 else if(hero_newstep_diag > 1)
14679 {
14680 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14681 hero_newstep_diag.doFloor();
14682 else --hero_newstep_diag;
14683 }
14684 else
14685 shiftdir = -1;
14686 }
14687 69 else break;
14688 }
14689 while(shiftdir != -1);
14690 69 break;
14691 }
14692 21 else break;
14693
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 45 times.
94 }
14694 94 while(shiftdir != -1);
14695 135 }
14696 }
14697
14698 2339 move(left);
14699 2339 shiftdir=s;
14700
14701
2/2
✓ Branch 0 taken 2104 times.
✓ Branch 1 taken 235 times.
2339 if(!walkable)
14702 {
14703
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 160 times.
235 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14704 {
14705 160 x = x.getInt();
14706 160 y = y.getInt();
14707 160 int32_t v1=bigHitbox?0:8;
14708 160 int32_t v2=bigHitbox?8:12;
14709
14710
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 145 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 150 times.
175 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
14711
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 10 times.
15 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
14712
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
14713 {
14714
4/8
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 10 times.
10 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
14715 10 sprite::move((zfix)0,(zfix)-1);
14716 10 }
14717
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 150 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 145 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 144 times.
295 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
14718
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 139 times.
✓ Branch 5 taken 6 times.
145 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
14719
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
14720 {
14721
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
6 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
14722 6 sprite::move((zfix)0,(zfix)1);
14723 6 }
14724 else
14725 {
14726 144 pushing=push+1;
14727 }
14728 160 }
14729 else
14730 {
14731 75 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14732
14733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(action!=swimming)
14734 {
14735 75 }
14736 }
14737 235 }
14738
14739 2339 return;
14740 }
14741 }
14742
14743
5/6
✓ Branch 0 taken 3853 times.
✓ Branch 1 taken 4116 times.
✓ Branch 2 taken 3750 times.
✓ Branch 3 taken 103 times.
✓ Branch 4 taken 3750 times.
✗ Branch 5 not taken.
7969 if(DrunkRight()&&(holddir==-1||holddir==right))
14744 {
14745
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3853 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3853 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14746 {
14747 }
14748 else
14749 {
14750
3/6
✓ Branch 0 taken 3853 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3853 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3853 times.
3853 if(charging==0 && spins==0 && action != sideswimattacking)
14751 {
14752 3853 dir=right;
14753 3853 }
14754 3853 sideswimdir = right;
14755
14756 3853 holddir=right;
14757
14758
3/4
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 3246 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 607 times.
3853 if(DrunkUp()&&shiftdir!=down)
14759 {
14760 607 shiftdir=up;
14761 607 }
14762
3/4
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 2931 times.
✓ Branch 2 taken 315 times.
✗ Branch 3 not taken.
3246 else if(DrunkDown()&&shiftdir!=up)
14763 {
14764 315 shiftdir=down;
14765 315 }
14766 else
14767 {
14768 2931 shiftdir=-1;
14769 }
14770
14771 3853 do
14772 {
14773 4280 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
14774
14775 4280 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
14776
14777 4280 execute(info);
14778
14779
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 3516 times.
4280 if(info.isUnwalkable())
14780 {
14781
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 758 times.
764 if(x != x.getInt())
14782 {
14783 6 x.doRound();
14784 6 }
14785
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 337 times.
758 else if(hero_newstep > 1)
14786 {
14787
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(hero_newstep != int32_t(hero_newstep)) //floor
14788 421 hero_newstep = floor((double)hero_newstep);
14789 else --hero_newstep;
14790 421 }
14791 else
14792 337 break;
14793 427 }
14794 3516 else walkable = true;
14795
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 3516 times.
3943 }
14796 3943 while(!walkable);
14797
14798 3853 int32_t s=shiftdir;
14799
14800
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 3853 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2440 times.
✓ Branch 7 taken 1413 times.
✓ Branch 8 taken 2422 times.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 2422 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2422 times.
✗ Branch 13 not taken.
3853 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14801 {
14802 2422 shiftdir=-1;
14803 2422 }
14804 else
14805 {
14806
2/2
✓ Branch 0 taken 1087 times.
✓ Branch 1 taken 344 times.
1431 if(s==up)
14807 {
14808 344 do
14809 {
14810 384 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14811
14812 384 execute(info);
14813
14814
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 309 times.
384 if(info.isUnwalkable())
14815 {
14816
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 70 times.
75 if(y != y.getInt())
14817 {
14818 5 y.doRound();
14819 5 }
14820
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 35 times.
70 else if(hero_newstep_diag > 1)
14821 {
14822
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14823 35 hero_newstep_diag.doFloor();
14824 else --hero_newstep_diag;
14825 35 }
14826 else
14827 35 shiftdir = -1;
14828 75 }
14829
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 82 times.
309 else if(walkable)
14830 {
14831 227 do
14832 {
14833 228 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14834 228 execute(info);
14835
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 227 times.
228 if(info.isUnwalkable())
14836 {
14837
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(y != y.getInt())
14838 {
14839 1 y.doRound();
14840 1 }
14841 else if(hero_newstep_diag > 1)
14842 {
14843 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14844 hero_newstep_diag.doFloor();
14845 else --hero_newstep_diag;
14846 }
14847 else
14848 shiftdir = -1;
14849 1 }
14850 227 else break;
14851
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 }
14852 1 while(shiftdir != -1);
14853 227 break;
14854 }
14855 82 else break;
14856
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 35 times.
75 }
14857 75 while(shiftdir != -1);
14858 344 }
14859
2/2
✓ Branch 0 taken 919 times.
✓ Branch 1 taken 168 times.
1087 else if(s==down)
14860 {
14861 168 do
14862 {
14863 224 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14864
14865 224 execute(info);
14866
14867
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 117 times.
224 if(info.isUnwalkable())
14868 {
14869
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if(y != y.getInt())
14870 {
14871 3 y.doRound();
14872 3 }
14873
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 51 times.
104 else if(hero_newstep_diag > 1)
14874 {
14875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14876 53 hero_newstep_diag.doFloor();
14877 else --hero_newstep_diag;
14878 53 }
14879 else
14880 51 shiftdir = -1;
14881 107 }
14882
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 14 times.
117 else if(walkable)
14883 {
14884 103 do
14885 {
14886 103 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
14887 103 execute(info);
14888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(info.isUnwalkable())
14889 {
14890 if(y != y.getInt())
14891 {
14892 y.doRound();
14893 }
14894 else if(hero_newstep_diag > 1)
14895 {
14896 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14897 hero_newstep_diag.doFloor();
14898 else --hero_newstep_diag;
14899 }
14900 else
14901 shiftdir = -1;
14902 }
14903 103 else break;
14904 }
14905 while(shiftdir != -1);
14906 103 break;
14907 }
14908 14 else break;
14909
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 51 times.
107 }
14910 107 while(shiftdir != -1);
14911 168 }
14912 }
14913
14914 3853 move(right);
14915 3853 shiftdir=s;
14916
14917
2/2
✓ Branch 0 taken 3516 times.
✓ Branch 1 taken 337 times.
3853 if(!walkable)
14918 {
14919
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 241 times.
337 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14920 {
14921 241 x = x.getInt();
14922 241 y = y.getInt();
14923 241 int32_t v1=bigHitbox?0:8;
14924 241 int32_t v2=bigHitbox?8:12;
14925
14926
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 241 times.
✓ Branch 2 taken 241 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 238 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 240 times.
244 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14927
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
3 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
14928
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14929 {
14930
4/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
14931 1 sprite::move((zfix)0,(zfix)-1);
14932 1 }
14933
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
✓ Branch 2 taken 240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 238 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 237 times.
478 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14934
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 238 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 238 times.
✓ Branch 4 taken 235 times.
✓ Branch 5 taken 3 times.
238 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
14935
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14936 {
14937
4/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
3 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
14938 3 sprite::move((zfix)0,(zfix)1);
14939 3 }
14940 else
14941 {
14942 237 pushing=push+1;
14943 237 z3step=2;
14944 }
14945 241 }
14946 else
14947 {
14948 96 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14949
14950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(action!=swimming)
14951 {
14952 96 }
14953 }
14954 337 }
14955
14956 3853 return;
14957 }
14958 }
14959 4116 }
14960 else
14961 {
14962
6/6
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 1353 times.
✓ Branch 2 taken 230 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 164 times.
✓ Branch 5 taken 66 times.
1591 if(DrunkUp()&&(holddir==-1||holddir==up))
14963 {
14964
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
74 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14965 {
14966 }
14967 else
14968 {
14969
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
74 if(charging==0 && spins==0)
14970 {
14971 74 dir=up;
14972 74 }
14973
14974 74 holddir=up;
14975
14976
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
74 if(DrunkRight()&&shiftdir!=left)
14977 {
14978 10 shiftdir=right;
14979 10 }
14980
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
64 else if(DrunkLeft()&&shiftdir!=right)
14981 {
14982 11 shiftdir=left;
14983 11 }
14984 else
14985 {
14986 53 shiftdir=-1;
14987 }
14988
14989 //walkable if Ladder can be placed or is already placed vertically
14990
1/18
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
74 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14991 {
14992 walkable=false;
14993 }
14994 else
14995 {
14996 74 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
14997
14998
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 39 times.
74 if(x.getInt() & 7)
14999 35 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15000 else
15001 39 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15002
15003 74 execute(info);
15004
15005
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 70 times.
74 if(info.isUnwalkable())
15006 {
15007
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(z3step==2)
15008 {
15009 4 z3step=1;
15010 4 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15011
15012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(x.getInt()&7)
15013 4 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15014 else
15015 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15016
15017 4 execute(info);
15018
15019
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(info.isUnwalkable())
15020 {
15021 4 walkable = false;
15022 4 }
15023 else
15024 {
15025 walkable=true;
15026 }
15027 4 }
15028 else
15029 {
15030 walkable=false;
15031 }
15032 4 }
15033 else
15034 {
15035 70 walkable = true;
15036 }
15037 }
15038
15039 74 int32_t s=shiftdir;
15040
15041
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
74 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15042 {
15043 shiftdir=-1;
15044 }
15045 else
15046 {
15047
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 63 times.
74 if(s==left)
15048 {
15049 11 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
15050 11 execute(info);
15051
15052
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
11 if(info.isUnwalkable())
15053 {
15054 2 shiftdir=-1;
15055 2 }
15056
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 else if(walkable)
15057 {
15058 8 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
15059 8 execute(info);
15060
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(info.isUnwalkable())
15061 {
15062 shiftdir=-1;
15063 }
15064 8 }
15065 11 }
15066
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 10 times.
63 else if(s==right)
15067 {
15068 10 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15069 10 execute(info);
15070
15071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(info.isUnwalkable())
15072 {
15073 shiftdir=-1;
15074 }
15075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 else if(walkable)
15076 {
15077 10 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
15078 10 execute(info);
15079
15080
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(info.isUnwalkable())
15081 {
15082 shiftdir=-1;
15083 }
15084 10 }
15085 10 }
15086 }
15087
15088 74 move(up);
15089 74 shiftdir=s;
15090
15091
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 4 times.
74 if(!walkable)
15092 {
15093
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15094 {
15095
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
3 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15096 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15097 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15098 {
15099 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15100 sprite::move((zfix)-1,(zfix)0);
15101 }
15102 else
15103 {
15104
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
6 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15105
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15106 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15107 {
15108 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15109 sprite::move((zfix)1,(zfix)0);
15110 }
15111 else
15112 {
15113 3 pushing=push+1;
15114 }
15115 }
15116
15117 3 z3step=2;
15118 3 }
15119 else
15120 {
15121 1 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15122 1 z3step=2;
15123 }
15124 4 }
15125
15126 74 return;
15127 }
15128 }
15129
15130
6/6
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 1256 times.
✓ Branch 2 taken 255 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 195 times.
✓ Branch 5 taken 60 times.
1517 if(DrunkDown()&&(holddir==-1||holddir==down))
15131 {
15132
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 201 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
201 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15133 {
15134 }
15135 else
15136 {
15137
2/4
✓ Branch 0 taken 201 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201 times.
✗ Branch 3 not taken.
201 if(charging==0 && spins==0)
15138 {
15139 201 dir=down;
15140 201 }
15141
15142 201 holddir=down;
15143
15144
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
201 if(DrunkRight()&&shiftdir!=left)
15145 {
15146 39 shiftdir=right;
15147 39 }
15148
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
162 else if(DrunkLeft()&&shiftdir!=right)
15149 {
15150 31 shiftdir=left;
15151 31 }
15152 else
15153 {
15154 131 shiftdir=-1;
15155 }
15156
15157 //bool walkable;
15158
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 201 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
201 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15159 {
15160 walkable=false;
15161 }
15162 else
15163 {
15164 201 info = walkflag(x,y+15+z3step,2,down);
15165
15166
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 100 times.
201 if(x.getInt()&7)
15167 101 info = info || walkflag(x+16,y+15+z3step,1,down);
15168 else
15169 100 info = info || walkflagMBlock(x+16, y+15+z3step);
15170
15171 201 execute(info);
15172
15173
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 190 times.
201 if(info.isUnwalkable())
15174 {
15175
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
11 if(z3step==2)
15176 {
15177 9 z3step=1;
15178 9 info = walkflag(x,y+15+z3step,2,down);
15179
15180
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(x.getInt()&7)
15181 9 info = info || walkflag(x+16,y+15+z3step,1,down);
15182 else
15183 info = info || walkflagMBlock(x+16, y+15+z3step);
15184
15185 9 execute(info);
15186
15187
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(info.isUnwalkable())
15188 {
15189 9 walkable = false;
15190 9 }
15191 else
15192 {
15193 walkable=true;
15194 }
15195 9 }
15196 else
15197 {
15198 2 walkable=false;
15199 }
15200 11 }
15201 else
15202 {
15203 190 walkable = true;
15204 }
15205 }
15206
15207 201 int32_t s=shiftdir;
15208
15209
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 201 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
201 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15210 {
15211 shiftdir=-1;
15212 }
15213 else
15214 {
15215
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 170 times.
201 if(s==left)
15216 {
15217 31 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15218 31 execute(info);
15219
15220
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 30 times.
31 if(info.isUnwalkable())
15221 {
15222 1 shiftdir=-1;
15223 1 }
15224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 else if(walkable)
15225 {
15226 30 info = walkflag(x-1,y+16,1,left);
15227 30 execute(info);
15228
15229
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(info.isUnwalkable())
15230 {
15231 shiftdir=-1;
15232 }
15233 30 }
15234 31 }
15235
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 39 times.
170 else if(s==right)
15236 {
15237 39 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15238 39 execute(info);
15239
15240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(info.isUnwalkable())
15241 {
15242 shiftdir=-1;
15243 }
15244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 else if(walkable)
15245 {
15246 39 info = walkflag(x+16,y+16,1,right);
15247 39 execute(info);
15248
15249
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(info.isUnwalkable())
15250 {
15251 shiftdir=-1;
15252 }
15253 39 }
15254 39 }
15255 }
15256
15257 201 move(down);
15258 201 shiftdir=s;
15259
15260
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 11 times.
201 if(!walkable)
15261 {
15262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15263 {
15264
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 5 times.
17 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15265
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15266
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15267 {
15268
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
6 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15269 6 sprite::move((zfix)-1,(zfix)0);
15270 6 }
15271
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
10 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15272
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
5 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15273
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15274 {
15275
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
5 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15276 5 sprite::move((zfix)1,(zfix)0);
15277 5 }
15278 else //if(shiftdir==-1)
15279 {
15280 pushing=push+1;
15281
15282 if(action!=swimming)
15283 {
15284 }
15285 }
15286
15287 11 z3step=2;
15288 11 }
15289 else
15290 {
15291 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15292
15293 if(action!=swimming)
15294 {
15295 }
15296
15297 z3step=2;
15298 }
15299 11 }
15300
15301 201 return;
15302 }
15303 }
15304
15305
6/6
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 921 times.
✓ Branch 2 taken 383 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 382 times.
✓ Branch 5 taken 1 times.
1316 if(DrunkLeft()&&(holddir==-1||holddir==left))
15306 {
15307
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
394 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15308 {
15309 }
15310 else
15311 {
15312
2/4
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 394 times.
394 if(charging==0 && spins==0)
15313 {
15314 394 dir=left;
15315 394 }
15316
15317 394 holddir=left;
15318
15319
3/4
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 252 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 142 times.
394 if(DrunkUp()&&shiftdir!=down)
15320 {
15321 142 shiftdir=up;
15322 142 }
15323
3/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
252 else if(DrunkDown()&&shiftdir!=up)
15324 {
15325 58 shiftdir=down;
15326 58 }
15327 else
15328 {
15329 194 shiftdir=-1;
15330 }
15331
15332 //bool walkable;
15333 394 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15334
15335
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 270 times.
394 if(y.getInt()&7)
15336 270 info = info || walkflag(x-z3step,y+16,1,left);
15337
15338 394 execute(info);
15339
15340
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 339 times.
394 if(info.isUnwalkable())
15341 {
15342
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
55 if(z3step==2)
15343 {
15344 54 z3step=1;
15345 54 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15346
15347
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 13 times.
54 if(y.getInt()&7)
15348 41 info = info || walkflag(x-z3step,y+16,1,left);
15349
15350 54 execute(info);
15351
15352
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 1 times.
54 if(info.isUnwalkable())
15353 {
15354 53 walkable = false;
15355 53 }
15356 else
15357 {
15358 1 walkable=true;
15359 }
15360 54 }
15361 else
15362 {
15363 1 walkable=false;
15364 }
15365 55 }
15366 else
15367 {
15368 339 walkable = true;
15369 }
15370
15371 394 int32_t s=shiftdir;
15372
15373
2/14
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 394 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
394 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15374 {
15375 shiftdir=-1;
15376 }
15377 else
15378 {
15379
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 142 times.
394 if(s==up)
15380 {
15381 142 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15382 142 execute(info);
15383
15384
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 136 times.
142 if(info.isUnwalkable())
15385 {
15386 6 shiftdir=-1;
15387 6 }
15388
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 100 times.
136 else if(walkable)
15389 {
15390 100 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15391 100 execute(info);
15392
15393
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(info.isUnwalkable())
15394 {
15395 shiftdir=-1;
15396 }
15397 100 }
15398 142 }
15399
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 58 times.
252 else if(s==down)
15400 {
15401 58 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15402 58 execute(info);
15403
15404
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 40 times.
58 if(info.isUnwalkable())
15405 {
15406 18 shiftdir=-1;
15407 18 }
15408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 else if(walkable)
15409 {
15410 40 info = walkflag(x-1,y+16,1,down);
15411 40 execute(info);
15412
15413
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(info.isUnwalkable())
15414 {
15415 shiftdir=-1;
15416 }
15417 40 }
15418 58 }
15419 }
15420
15421 394 move(left);
15422 394 shiftdir=s;
15423
15424
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 54 times.
394 if(!walkable)
15425 {
15426
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 18 times.
54 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15427 {
15428 18 int32_t v1=bigHitbox?0:8;
15429 18 int32_t v2=bigHitbox?8:12;
15430
15431
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 18 times.
18 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15432 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15433 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15434 {
15435 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15436 sprite::move((zfix)0,(zfix)-1);
15437 }
15438
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 18 times.
36 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15439
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
18 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15440 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15441 {
15442 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15443 sprite::move((zfix)0,(zfix)1);
15444 }
15445 else //if(shiftdir==-1)
15446 {
15447 18 pushing=push+1;
15448
15449
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(action!=swimming)
15450 {
15451 }
15452 }
15453
15454 18 z3step=2;
15455 18 }
15456 else
15457 {
15458 36 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15459
15460
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(action!=swimming)
15461 {
15462 }
15463
15464 36 z3step=2;
15465 }
15466 54 }
15467
15468 394 return;
15469 }
15470 }
15471
15472
5/6
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 800 times.
✓ Branch 2 taken 118 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 118 times.
✗ Branch 5 not taken.
922 if(DrunkRight()&&(holddir==-1||holddir==right))
15473 {
15474
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
122 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15475 {
15476 }
15477 else
15478 {
15479
2/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
122 if(charging==0 && spins==0)
15480 {
15481 122 dir=right;
15482 122 }
15483
15484 122 holddir=right;
15485
15486
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
122 if(DrunkUp()&&shiftdir!=down)
15487 {
15488 22 shiftdir=up;
15489 22 }
15490
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
100 else if(DrunkDown()&&shiftdir!=up)
15491 {
15492 2 shiftdir=down;
15493 2 }
15494 else
15495 {
15496 98 shiftdir=-1;
15497 }
15498
15499 //bool walkable;
15500 122 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15501
15502
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 74 times.
122 if(y.getInt()&7)
15503 74 info = info || walkflag(x+15+z3step,y+16,1,right);
15504
15505 122 execute(info);
15506
15507
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115 times.
122 if(info.isUnwalkable())
15508 {
15509
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(z3step==2)
15510 {
15511 7 z3step=1;
15512 7 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15513
15514
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(y.getInt()&7)
15515 4 info = info || walkflag(x+15+z3step,y+16,1,right);
15516
15517 7 execute(info);
15518
15519
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(info.isUnwalkable())
15520 {
15521 5 walkable = false;
15522 5 }
15523 else
15524 {
15525 2 walkable=true;
15526 }
15527 7 }
15528 else
15529 {
15530 walkable=false;
15531 }
15532 7 }
15533 else
15534 {
15535 115 walkable = true;
15536 }
15537
15538 122 int32_t s=shiftdir;
15539
15540
2/14
✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 122 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
122 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15541 {
15542 shiftdir=-1;
15543 }
15544 else
15545 {
15546
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 22 times.
122 if(s==up)
15547 {
15548 22 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15549 22 execute(info);
15550
15551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(info.isUnwalkable())
15552 {
15553 shiftdir=-1;
15554 }
15555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 else if(walkable)
15556 {
15557 22 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15558 22 execute(info);
15559
15560
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(info.isUnwalkable())
15561 {
15562 shiftdir=-1;
15563 }
15564 22 }
15565 22 }
15566
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 2 times.
100 else if(s==down)
15567 {
15568 2 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15569 2 execute(info);
15570
15571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(info.isUnwalkable())
15572 {
15573 shiftdir=-1;
15574 }
15575
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(walkable)
15576 {
15577 info = walkflag(x+16,y+16,1,down);
15578 execute(info);
15579
15580 if(info.isUnwalkable())
15581 {
15582 shiftdir=-1;
15583 }
15584 }
15585 2 }
15586 }
15587
15588 122 move(right);
15589 122 shiftdir=s;
15590
15591
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 5 times.
122 if(!walkable)
15592 {
15593
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
5 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15594 {
15595 3 int32_t v1=bigHitbox?0:8;
15596 3 int32_t v2=bigHitbox?8:12;
15597
15598 9 info = !walkflag(x+16,y+v1,1,right)&&
15599 6 !walkflag(x+16,y+v2,1,right)&&
15600 3 walkflag(x+16,y+15,1,right);
15601
15602 //do NOT execute these
15603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(info.isUnwalkable())
15604 {
15605 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15606 sprite::move((zfix)0,(zfix)-1);
15607 }
15608 else
15609 {
15610 9 info = walkflag(x+16,y+v1, 1,right)&&
15611 6 !walkflag(x+16,y+v2-1,1,right)&&
15612 3 !walkflag(x+16,y+15, 1,right);
15613
15614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(info.isUnwalkable())
15615 {
15616 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15617 sprite::move((zfix)0,(zfix)1);
15618 }
15619 else //if(shiftdir==-1)
15620 {
15621 3 pushing=push+1;
15622 3 z3step=2;
15623
15624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(action!=swimming)
15625 {
15626 3 }
15627 }
15628 }
15629
15630 3 z3step=2;
15631 3 }
15632 else
15633 {
15634 2 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15635
15636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(action!=swimming)
15637 {
15638 2 }
15639
15640 2 z3step=2;
15641 }
15642 5 }
15643
15644 122 return;
15645 }
15646 }
15647 }
15648
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4916 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4916 if(shield_forcedir > -1 && action != rafting)
15649 dir = shield_forcedir;
15650 4916 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
15651 4916 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
15652 4916 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
15653 4916 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
15654 4916 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
15655
15656
7/12
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 4116 times.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 800 times.
✓ Branch 6 taken 800 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 800 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 800 times.
4916 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
15657 {
15658
6/12
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 775 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
800 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
15659 {
15660 //action=swimming;
15661
2/12
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
25 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
15662 {
15663 hopclk = 0xFF;
15664 }
15665 25 }
15666 800 }
15667
15668 4916 return;
15669 } //endif (LTTPWALK)
15670 22212 temp_step = hero_newstep;
15671 22212 temp_x = x;
15672 22212 temp_y = y;
15673
15674
7/8
✓ Branch 0 taken 14439 times.
✓ Branch 1 taken 7773 times.
✓ Branch 2 taken 14259 times.
✓ Branch 3 taken 180 times.
✓ Branch 4 taken 137 times.
✓ Branch 5 taken 14302 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 137 times.
22212 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15675 {
15676
2/4
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
137 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15677 goto LEFTRIGHT_NEWMOVE;
15678 137 else goto LEFTRIGHT_OLDMOVE;
15679 }
15680
15681 // make it easier to get in left & right doors
15682
15683 //ignore ladder for this part. sigh sigh sigh -DD
15684 22075 oldladderx = ladderx;
15685 22075 oldladdery = laddery;
15686
2/4
✓ Branch 0 taken 22075 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22075 times.
22075 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15687 {
15688 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
15689 {
15690 do
15691 {
15692 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
15693 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
15694
15695 if(info.isUnwalkable())
15696 {
15697 if(temp_x != int32_t(temp_x))
15698 {
15699 temp_x = floor((double)temp_x);
15700 }
15701 else if(temp_step > 1)
15702 {
15703 if(temp_step != int32_t(temp_step)) //floor
15704 temp_step = floor((double)temp_step);
15705 else --temp_step;
15706 }
15707 else
15708 break;
15709 }
15710 }
15711 while(info.isUnwalkable());
15712
15713 if(!info.isUnwalkable())
15714 {
15715 x = temp_x;
15716 y = temp_y;
15717 hero_newstep = temp_step;
15718 //ONLY process the side-effects of the above walkflag if Hero will actually move
15719 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
15720 execute(info);
15721 move(left);
15722 return;
15723 }
15724 temp_x = x;
15725 temp_y = y;
15726 temp_step = hero_newstep;
15727 }
15728
15729 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
15730 {
15731 do
15732 {
15733 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
15734 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15735
15736 if(info.isUnwalkable())
15737 {
15738 if(temp_x != int32_t(temp_x))
15739 {
15740 temp_x = floor((double)temp_x);
15741 }
15742 else if(temp_step > 1)
15743 {
15744 if(temp_step != int32_t(temp_step)) //floor
15745 temp_step = floor((double)temp_step);
15746 else --temp_step;
15747 }
15748 else
15749 break;
15750 }
15751 }
15752 while(info.isUnwalkable());
15753
15754 if(!info.isUnwalkable())
15755 {
15756 x = temp_x;
15757 y = temp_y;
15758 hero_newstep = temp_step;
15759 execute(info);
15760 move(right);
15761 return;
15762 }
15763 temp_x = x;
15764 temp_y = y;
15765 temp_step = hero_newstep;
15766 }
15767
15768 ladderx = oldladderx;
15769 laddery = oldladdery;
15770
15771 if(DrunkUp())
15772 {
15773 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15774 {
15775 if(dir!=up && dir!=down)
15776 {
15777 if(xoff>2&&xoff<6)
15778 {
15779 move(dir);
15780 }
15781 else if(xoff>=6)
15782 {
15783 move(right);
15784 }
15785 else if(xoff>=1)
15786 {
15787 move(left);
15788 }
15789 }
15790 else
15791 {
15792 if(xoff>=4)
15793 {
15794 move(right);
15795 }
15796 else if(xoff<4)
15797 {
15798 move(left);
15799 }
15800 }
15801 }
15802 else
15803 {
15804 do
15805 {
15806 if(action==swimming || IsSideSwim() || action == swimhit)
15807 {
15808 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15809
15810 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
15811 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
15812 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
15813 info.setUnwalkable(true);
15814 }
15815 else
15816 {
15817 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15818 if(x.getInt() & 7)
15819 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
15820 else
15821 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
15822 }
15823
15824 if(info.isUnwalkable())
15825 {
15826 if(temp_y != int32_t(temp_y))
15827 {
15828 temp_y = floor((double)temp_y);
15829 }
15830 else if(temp_step > 1)
15831 {
15832 if(temp_step != int32_t(temp_step)) //floor
15833 temp_step = floor((double)temp_step);
15834 else --temp_step;
15835 }
15836 else
15837 break;
15838 }
15839 }
15840 while(info.isUnwalkable());
15841
15842 execute(info);
15843
15844 if(!info.isUnwalkable())
15845 {
15846 x = temp_x;
15847 y = temp_y;
15848 hero_newstep = temp_step;
15849 move(up);
15850 return;
15851 }
15852
15853 if(!DrunkLeft() && !DrunkRight())
15854 {
15855 if(NO_GRIDLOCK)
15856 {
15857 x = x.getInt();
15858 y = y.getInt();
15859 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15860 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15861 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15862 {
15863 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15864 sprite::move((zfix)-1,(zfix)0);
15865 }
15866 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15867 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15868 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15869 {
15870 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15871 sprite::move((zfix)1,(zfix)0);
15872 }
15873 else
15874 {
15875 pushing=push+1;
15876 }
15877 }
15878 else pushing=push+1;
15879
15880 if(charging==0 && spins==0)
15881 {
15882 dir=up;
15883 }
15884
15885 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15886 {
15887 herostep();
15888 }
15889
15890 return;
15891 }
15892 else
15893 {
15894 goto LEFTRIGHT_NEWMOVE;
15895 }
15896 }
15897
15898 return;
15899 }
15900
15901 if(DrunkDown())
15902 {
15903 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15904 {
15905 if(dir!=up && dir!=down)
15906 {
15907 if(xoff>2&&xoff<6)
15908 {
15909 move(dir);
15910 }
15911 else if(xoff>=6)
15912 {
15913 move(right);
15914 }
15915 else if(xoff>=1)
15916 {
15917 move(left);
15918 }
15919 }
15920 else
15921 {
15922 if(xoff>=4)
15923 {
15924 move(right);
15925 }
15926 else if(xoff<4)
15927 {
15928 move(left);
15929 }
15930 }
15931 }
15932 else
15933 {
15934 do
15935 {
15936 if(action==swimming || IsSideSwim() || action == swimhit)
15937 {
15938 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15939
15940 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
15941 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
15942 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
15943 info.setUnwalkable(true);
15944 }
15945 else
15946 {
15947 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15948 if(x.getInt() & 7)
15949 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
15950 else
15951 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
15952 }
15953
15954 if(info.isUnwalkable())
15955 {
15956 if(temp_y != int32_t(temp_y))
15957 {
15958 temp_y = floor((double)temp_y);
15959 }
15960 else if(temp_step > 1)
15961 {
15962 if(temp_step != int32_t(temp_step)) //floor
15963 temp_step = floor((double)temp_step);
15964 else --temp_step;
15965 }
15966 else
15967 break;
15968 }
15969 }
15970 while(info.isUnwalkable());
15971
15972 execute(info);
15973
15974 if(!info.isUnwalkable())
15975 {
15976 x = temp_x;
15977 y = temp_y;
15978 hero_newstep = temp_step;
15979 move(down);
15980 return;
15981 }
15982
15983 if(!DrunkLeft() && !DrunkRight())
15984 {
15985 if(NO_GRIDLOCK)
15986 {
15987 x = x.getInt();
15988 y = y.getInt();
15989 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15990 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15991 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15992 {
15993 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15994 sprite::move((zfix)-1,(zfix)0);
15995 }
15996 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15997 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15998 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15999 {
16000 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16001 sprite::move((zfix)1,(zfix)0);
16002 }
16003 else
16004 {
16005 pushing=push+1;
16006 }
16007 }
16008 else pushing=push+1;
16009
16010 if(charging==0 && spins==0)
16011 {
16012 dir=down;
16013 }
16014
16015 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16016 {
16017 herostep();
16018 }
16019
16020 return;
16021 }
16022 else goto LEFTRIGHT_NEWMOVE;
16023 }
16024
16025 return;
16026 }
16027
16028 LEFTRIGHT_NEWMOVE:
16029 temp_x = x;
16030 temp_y = y;
16031 temp_step = hero_newstep;
16032 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16033 {
16034 return;
16035 }
16036
16037 if(DrunkLeft())
16038 {
16039 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16040 {
16041 if(dir!=left && dir!=right)
16042 {
16043 if(yoff>2&&yoff<6)
16044 {
16045 move(dir);
16046 }
16047 else if(yoff>=6)
16048 {
16049 move(down);
16050 }
16051 else if(yoff>=1)
16052 {
16053 move(up);
16054 }
16055 }
16056 else
16057 {
16058 if(yoff>=4)
16059 {
16060 move(down);
16061 }
16062 else if(yoff<4)
16063 {
16064 move(up);
16065 }
16066 }
16067 }
16068 else
16069 {
16070 do
16071 {
16072 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
16073 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
16074
16075 if(y.getInt() & 7)
16076 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
16077
16078 if(info.isUnwalkable())
16079 {
16080 if(temp_x != int32_t(temp_x))
16081 {
16082 temp_x = floor((double)temp_x);
16083 }
16084 else if(temp_step > 1)
16085 {
16086 if(temp_step != int32_t(temp_step)) //floor
16087 temp_step = floor((double)temp_step);
16088 else --temp_step;
16089 }
16090 else
16091 break;
16092 }
16093 }
16094 while(info.isUnwalkable());
16095
16096 execute(info);
16097
16098 if(!info.isUnwalkable())
16099 {
16100 x = temp_x;
16101 y = temp_y;
16102 hero_newstep = temp_step;
16103 move(left);
16104 return;
16105 }
16106
16107 if(!DrunkUp() && !DrunkDown())
16108 {
16109 if(NO_GRIDLOCK)
16110 {
16111 x = x.getInt();
16112 y = y.getInt();
16113 int32_t v1=bigHitbox?0:8;
16114 int32_t v2=bigHitbox?8:12;
16115
16116 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16117 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16118 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16119 {
16120 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16121 sprite::move((zfix)0,(zfix)-1);
16122 }
16123 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16124 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16125 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16126 {
16127 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16128 sprite::move((zfix)0,(zfix)1);
16129 }
16130 else
16131 {
16132 pushing=push+1;
16133 }
16134 }
16135 else pushing=push+1;
16136
16137 if(charging==0 && spins==0)
16138 {
16139 dir=left;
16140 }
16141
16142 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16143 {
16144 herostep();
16145 }
16146
16147 return;
16148 }
16149 }
16150
16151 return;
16152 }
16153
16154 if(DrunkRight())
16155 {
16156 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16157 {
16158 if(dir!=left && dir!=right)
16159 {
16160 if(yoff>2&&yoff<6)
16161 {
16162 move(dir);
16163 }
16164 else if(yoff>=6)
16165 {
16166 move(down);
16167 }
16168 else if(yoff>=1)
16169 {
16170 move(up);
16171 }
16172 }
16173 else
16174 {
16175 if(yoff>=4)
16176 {
16177 move(down);
16178 }
16179 else if(yoff<4)
16180 {
16181 move(up);
16182 }
16183 }
16184 }
16185 else
16186 {
16187 do
16188 {
16189 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16190 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16191
16192 if(y.getInt() & 7)
16193 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16194
16195 if(info.isUnwalkable())
16196 {
16197 if(temp_x != int32_t(temp_x))
16198 {
16199 temp_x = floor((double)temp_x);
16200 }
16201 else if(temp_step > 1)
16202 {
16203 if(temp_step != int32_t(temp_step)) //floor
16204 temp_step = floor((double)temp_step);
16205 else --temp_step;
16206 }
16207 else
16208 break;
16209 }
16210 }
16211 while(info.isUnwalkable());
16212
16213 execute(info);
16214
16215 if(!info.isUnwalkable())
16216 {
16217 x = temp_x;
16218 y = temp_y;
16219 hero_newstep = temp_step;
16220 move(right);
16221 return;
16222 }
16223
16224 if(!DrunkUp() && !DrunkDown())
16225 {
16226 if(NO_GRIDLOCK)
16227 {
16228 x = x.getInt();
16229 y = y.getInt();
16230 int32_t v1=bigHitbox?0:8;
16231 int32_t v2=bigHitbox?8:12;
16232
16233 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16234 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16235 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16236 {
16237 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16238 sprite::move((zfix)0,(zfix)-1);
16239 }
16240 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16241 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16242 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16243 {
16244 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16245 sprite::move((zfix)0,(zfix)1);
16246 }
16247 else
16248 {
16249 pushing=push+1;
16250 }
16251 }
16252 else pushing=push+1;
16253
16254 if(charging==0 && spins==0)
16255 {
16256 dir=right;
16257 }
16258
16259 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16260 {
16261 herostep();
16262 }
16263
16264 return;
16265 }
16266 }
16267 }
16268 }
16269 else
16270 {
16271 44150 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16272 22075 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16273
16274
9/10
✓ Branch 0 taken 14302 times.
✓ Branch 1 taken 7773 times.
✓ Branch 2 taken 2088 times.
✓ Branch 3 taken 12214 times.
✓ Branch 4 taken 1395 times.
✓ Branch 5 taken 693 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 1379 times.
✓ Branch 8 taken 16 times.
✗ Branch 9 not taken.
22075 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16275 {
16276 //ONLY process the side-effects of the above walkflag if Hero will actually move
16277 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16278 16 execute(info);
16279 16 move(left);
16280 16 return;
16281 }
16282
16283 44118 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16284 22059 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16285
16286
9/10
✓ Branch 0 taken 14286 times.
✓ Branch 1 taken 7773 times.
✓ Branch 2 taken 2811 times.
✓ Branch 3 taken 11475 times.
✓ Branch 4 taken 1609 times.
✓ Branch 5 taken 1202 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 1583 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 26 times.
22059 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16287 {
16288 26 execute(info);
16289 26 move(right);
16290 26 return;
16291 }
16292
16293 22033 ladderx = oldladderx;
16294 22033 laddery = oldladdery;
16295
16296
2/2
✓ Branch 0 taken 3091 times.
✓ Branch 1 taken 18942 times.
22033 if(DrunkUp())
16297 {
16298
8/14
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 3034 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 57 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 57 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 57 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 57 times.
3091 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16299 {
16300
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
57 if(dir!=up && dir!=down)
16301 {
16302
4/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 20 times.
57 if(xoff>2&&xoff<6)
16303 {
16304 20 move(dir);
16305 20 }
16306
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 21 times.
37 else if(xoff>=6)
16307 {
16308 16 move(right);
16309 16 }
16310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 else if(xoff>=1)
16311 {
16312 21 move(left);
16313 21 }
16314 57 }
16315 else
16316 {
16317 if(xoff>=4)
16318 {
16319 move(right);
16320 }
16321 else if(xoff<4)
16322 {
16323 move(left);
16324 }
16325 }
16326 57 }
16327 else
16328 {
16329
3/6
✓ Branch 0 taken 3034 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3034 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3034 times.
3034 if(action==swimming || IsSideSwim() || action == swimhit)
16330 {
16331 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16332
16333 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16334 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16335 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16336 info.setUnwalkable(true);
16337 }
16338 else
16339 {
16340 3034 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3034 times.
3034 if(x.getInt() & 7)
16342 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16343 else
16344 3034 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16345 }
16346
16347 3034 execute(info);
16348
16349
2/2
✓ Branch 0 taken 1385 times.
✓ Branch 1 taken 1649 times.
3034 if(!info.isUnwalkable())
16350 {
16351 1649 move(up);
16352 1649 return;
16353 }
16354
16355
4/4
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 117 times.
✓ Branch 3 taken 1157 times.
1385 if(!DrunkLeft() && !DrunkRight())
16356 {
16357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1157 times.
1157 if(NO_GRIDLOCK)
16358 {
16359 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16360 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16361 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16362 {
16363 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16364 sprite::move((zfix)-1,(zfix)0);
16365 }
16366 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16367 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16368 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16369 {
16370 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16371 sprite::move((zfix)1,(zfix)0);
16372 }
16373 else
16374 {
16375 pushing=push+1;
16376 }
16377 }
16378 1157 else pushing=push+1;
16379
16380
2/4
✓ Branch 0 taken 1157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1157 times.
✗ Branch 3 not taken.
1157 if(charging==0 && spins==0)
16381 {
16382 1157 dir=up;
16383 1157 }
16384
16385
4/8
✓ Branch 0 taken 1157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1157 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1157 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1157 times.
1157 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16386 {
16387 1157 herostep();
16388 1157 }
16389
16390 1157 return;
16391 }
16392 else
16393 {
16394 228 goto LEFTRIGHT_OLDMOVE;
16395 }
16396 }
16397
16398 57 return;
16399 }
16400
16401
2/2
✓ Branch 0 taken 1682 times.
✓ Branch 1 taken 17260 times.
18942 if(DrunkDown())
16402 {
16403
8/14
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 1645 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 37 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 37 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 37 times.
1682 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16404 {
16405
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
37 if(dir!=up && dir!=down)
16406 {
16407
4/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 14 times.
37 if(xoff>2&&xoff<6)
16408 {
16409 14 move(dir);
16410 14 }
16411
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 8 times.
23 else if(xoff>=6)
16412 {
16413 15 move(right);
16414 15 }
16415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if(xoff>=1)
16416 {
16417 8 move(left);
16418 8 }
16419 37 }
16420 else
16421 {
16422 if(xoff>=4)
16423 {
16424 move(right);
16425 }
16426 else if(xoff<4)
16427 {
16428 move(left);
16429 }
16430 }
16431 37 }
16432 else
16433 {
16434
3/6
✓ Branch 0 taken 1645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1645 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1645 times.
1645 if(action==swimming || IsSideSwim() || action == swimhit)
16435 {
16436 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16437
16438 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16439 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16440 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16441 info.setUnwalkable(true);
16442 }
16443 else
16444 {
16445 1645 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1645 times.
1645 if(x.getInt() & 7)
16447 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16448 else
16449 1645 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16450 }
16451
16452 1645 execute(info);
16453
16454
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 1041 times.
1645 if(!info.isUnwalkable())
16455 {
16456 1041 move(down);
16457 1041 return;
16458 }
16459
16460
4/4
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 513 times.
604 if(!DrunkLeft() && !DrunkRight())
16461 {
16462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 513 times.
513 if(NO_GRIDLOCK)
16463 {
16464 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16465 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16466 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16467 {
16468 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16469 sprite::move((zfix)-1,(zfix)0);
16470 }
16471 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16472 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16473 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16474 {
16475 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16476 sprite::move((zfix)1,(zfix)0);
16477 }
16478 else
16479 {
16480 pushing=push+1;
16481 }
16482 }
16483 513 else pushing=push+1;
16484
16485
2/4
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
✗ Branch 3 not taken.
513 if(charging==0 && spins==0)
16486 {
16487 513 dir=down;
16488 513 }
16489
16490
4/8
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 513 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 513 times.
513 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16491 {
16492 513 herostep();
16493 513 }
16494
16495 513 return;
16496 }
16497 91 else goto LEFTRIGHT_OLDMOVE;
16498 }
16499
16500 37 return;
16501 }
16502
16503 LEFTRIGHT_OLDMOVE:
16504
16505
7/8
✓ Branch 0 taken 11304 times.
✓ Branch 1 taken 6412 times.
✓ Branch 2 taken 11146 times.
✓ Branch 3 taken 158 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 11242 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
17716 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16506 {
16507 62 return;
16508 }
16509
16510
2/2
✓ Branch 0 taken 2658 times.
✓ Branch 1 taken 14996 times.
17654 if(DrunkLeft())
16511 {
16512
8/14
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2623 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 35 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 35 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 35 times.
2658 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16513 {
16514
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(dir!=left && dir!=right)
16515 {
16516
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 11 times.
35 if(yoff>2&&yoff<6)
16517 {
16518 11 move(dir);
16519 11 }
16520
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 13 times.
24 else if(yoff>=6)
16521 {
16522 11 move(down);
16523 11 }
16524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 else if(yoff>=1)
16525 {
16526 13 move(up);
16527 13 }
16528 35 }
16529 else
16530 {
16531 if(yoff>=4)
16532 {
16533 move(down);
16534 }
16535 else if(yoff<4)
16536 {
16537 move(up);
16538 }
16539 }
16540 35 }
16541 else
16542 {
16543 5246 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16544 2623 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16545
16546 2623 execute(info);
16547
16548
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 1912 times.
2623 if(!info.isUnwalkable())
16549 {
16550 1912 move(left);
16551 1912 return;
16552 }
16553
16554
4/4
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 665 times.
711 if(!DrunkUp() && !DrunkDown())
16555 {
16556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 665 times.
665 if(NO_GRIDLOCK)
16557 {
16558 int32_t v1=bigHitbox?0:8;
16559 int32_t v2=bigHitbox?8:12;
16560
16561 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16562 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16563 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16564 {
16565 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16566 sprite::move((zfix)0,(zfix)-1);
16567 }
16568 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16569 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16570 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16571 {
16572 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16573 sprite::move((zfix)0,(zfix)1);
16574 }
16575 else
16576 {
16577 pushing=push+1;
16578 }
16579 }
16580 665 else pushing=push+1;
16581
16582
2/4
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 665 times.
665 if(charging==0 && spins==0)
16583 {
16584 665 dir=left;
16585 665 }
16586
16587
4/8
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 665 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 665 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 665 times.
665 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16588 {
16589 665 herostep();
16590 665 }
16591
16592 665 return;
16593 }
16594 }
16595
16596 81 return;
16597 }
16598
16599
2/2
✓ Branch 0 taken 11564 times.
✓ Branch 1 taken 3432 times.
14996 if(DrunkRight())
16600 {
16601
8/14
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 3399 times.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 33 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 33 times.
3432 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16602 {
16603
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(dir!=left && dir!=right)
16604 {
16605
4/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
33 if(yoff>2&&yoff<6)
16606 {
16607 18 move(dir);
16608 18 }
16609
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 10 times.
15 else if(yoff>=6)
16610 {
16611 5 move(down);
16612 5 }
16613
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 else if(yoff>=1)
16614 {
16615 10 move(up);
16616 10 }
16617 33 }
16618 else
16619 {
16620 if(yoff>=4)
16621 {
16622 move(down);
16623 }
16624 else if(yoff<4)
16625 {
16626 move(up);
16627 }
16628 }
16629 33 }
16630 else
16631 {
16632 6798 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
16633 3399 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
16634
16635 3399 execute(info);
16636
16637
2/2
✓ Branch 0 taken 1237 times.
✓ Branch 1 taken 2162 times.
3399 if(!info.isUnwalkable())
16638 {
16639 2162 move(right);
16640 2162 return;
16641 }
16642
16643
3/4
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1228 times.
1237 if(!DrunkUp() && !DrunkDown())
16644 {
16645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(NO_GRIDLOCK)
16646 {
16647 int32_t v1=bigHitbox?0:8;
16648 int32_t v2=bigHitbox?8:12;
16649
16650 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16651 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16652 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16653 {
16654 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16655 sprite::move((zfix)0,(zfix)-1);
16656 }
16657 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16658 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16659 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16660 {
16661 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16662 sprite::move((zfix)0,(zfix)1);
16663 }
16664 else
16665 {
16666 pushing=push+1;
16667 }
16668 }
16669 1228 else pushing=push+1;
16670
16671
2/4
✓ Branch 0 taken 1228 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1228 times.
1228 if(charging==0 && spins==0)
16672 {
16673 1228 dir=right;
16674 1228 }
16675
16676
4/8
✓ Branch 0 taken 1228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1228 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1228 times.
1228 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16677 {
16678 1228 herostep();
16679 1228 }
16680
16681 1228 return;
16682 }
16683 }
16684 42 }
16685 }
16686 75736 }
16687
16688 //solid ffc checking should probably be moved to here.
16689 47727 void HeroClass::move(int32_t d2, int32_t forceRate)
16690 {
16691
3/6
✓ Branch 0 taken 47727 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47727 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47727 times.
47727 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16692 return;
16693
16694
3/4
✓ Branch 0 taken 39132 times.
✓ Branch 1 taken 8595 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39132 times.
47727 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
16695 {
16696 39132 moveOld(d2);
16697 39132 return;
16698 }
16699
16700
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8595 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17190 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
16701
5/6
✓ Branch 0 taken 4699 times.
✓ Branch 1 taken 3896 times.
✓ Branch 2 taken 1836 times.
✓ Branch 3 taken 2863 times.
✓ Branch 4 taken 4699 times.
✗ Branch 5 not taken.
8595 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
16702 //!DIMITODO: add QR for slow combos under hero
16703
2/2
✓ Branch 0 taken 17190 times.
✓ Branch 1 taken 8595 times.
25785 for (int32_t i = 0; i <= 1; ++i)
16704 {
16705
2/2
✓ Branch 0 taken 14748 times.
✓ Branch 1 taken 2442 times.
17190 if(tmpscr2[i].valid!=0)
16706 {
16707
1/2
✓ Branch 0 taken 2442 times.
✗ Branch 1 not taken.
2442 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
16708 {
16709 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16710 }
16711 else
16712 {
16713
2/4
✓ Branch 0 taken 2442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2442 times.
✗ Branch 3 not taken.
2442 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16714 }
16715 2442 }
16716 17190 }
16717
1/2
✓ Branch 0 taken 8595 times.
✗ Branch 1 not taken.
8595 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
16718 8595 bool is_swimming = (action == swimming);
16719 8595 bool fastSwim = (zinit.hero_swim_speed>60);
16720 8595 zfix rate(steprate);
16721 8595 int32_t shieldid = getCurrentActiveShield();
16722
1/2
✓ Branch 0 taken 8595 times.
✗ Branch 1 not taken.
8595 if(shieldid > -1)
16723 {
16724 itemdata const& shield = itemsbuf[shieldid];
16725 if(shield.flags & ITEM_FLAG10) //Change Speed flag
16726 {
16727 zfix perc = shield.misc7;
16728 perc /= 100;
16729 if(perc < 0)
16730 perc = (perc*-1)+1;
16731 rate = (rate * perc) + shield.misc8;
16732 }
16733 }
16734
16735 8595 zfix dx, dy;
16736 8595 zfix movepix(rate / 100);
16737 8595 zfix step(movepix);
16738 8595 zfix step_diag(movepix);
16739 8595 zfix up_step(game->get_sideswim_up() / -100.0);
16740 8595 zfix left_step(game->get_sideswim_side() / -100.0);
16741 8595 zfix right_step(game->get_sideswim_side() / 100.0);
16742 8595 zfix down_step(game->get_sideswim_down() / 100.0);
16743 8595 bool checkladder = false;
16744
16745
1/2
✓ Branch 0 taken 8595 times.
✗ Branch 1 not taken.
8595 if(hero_newstep > movepix) hero_newstep = movepix;
16746
1/2
✓ Branch 0 taken 8595 times.
✗ Branch 1 not taken.
8595 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
16747 //2/3 speed
16748
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8595 times.
✓ Branch 2 taken 8595 times.
✓ Branch 3 taken 8595 times.
✓ Branch 4 taken 8595 times.
✓ Branch 5 taken 8595 times.
8595 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
16749 {
16750 17190 step = ((step / 3.0) * 2);
16751 17190 step_diag = ((step_diag / 3.0) * 2);
16752 17190 up_step = ((up_step / 3.0) * 2);
16753 17190 left_step = ((left_step / 3.0) * 2);
16754 17190 right_step = ((right_step / 3.0) * 2);
16755 17190 down_step = ((down_step / 3.0) * 2);
16756 17190 }
16757 //1/2 speed
16758
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8595 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8595 times.
8595 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
16759 {
16760 step /= 2;
16761 step_diag /= 2;
16762 up_step /= 2;
16763 left_step /= 2;
16764 right_step /= 2;
16765 down_step /= 2;
16766 }
16767 //normal speed
16768 else
16769 {
16770 //no modification
16771 }
16772
16773
1/2
✓ Branch 0 taken 8595 times.
✗ Branch 1 not taken.
8595 if(diagonalMovement)
16774 {
16775 //zprint2("Player's X is %d, Y is %d\n", x, y);
16776
6/6
✓ Branch 0 taken 7866 times.
✓ Branch 1 taken 729 times.
✓ Branch 2 taken 7006 times.
✓ Branch 3 taken 860 times.
✓ Branch 4 taken 1965 times.
✓ Branch 5 taken 5770 times.
14308 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
16777
4/4
✓ Branch 0 taken 5034 times.
✓ Branch 1 taken 4174 times.
✓ Branch 2 taken 1539 times.
✓ Branch 3 taken 3495 times.
860 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
16778 {
16779
2/4
✓ Branch 0 taken 1908 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1908 times.
13448 if(hero_newstep > 0 && hero_newstep_diag > 0)
16780 {
16781 1908 step = STEP_DIAGONAL(step);
16782 1908 step_diag = STEP_DIAGONAL(step_diag);
16783 1908 up_step = STEP_DIAGONAL(up_step);
16784 1908 left_step = STEP_DIAGONAL(left_step);
16785 1908 right_step = STEP_DIAGONAL(right_step);
16786 1908 down_step = STEP_DIAGONAL(down_step);
16787 1908 }
16788 1908 }
16789
2/2
✓ Branch 0 taken 4175 times.
✓ Branch 1 taken 1228 times.
5403 if(hero_newstep < step) step = hero_newstep; //handle collision
16790
2/2
✓ Branch 0 taken 5125 times.
✓ Branch 1 taken 278 times.
5403 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
16791
5/5
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 729 times.
✓ Branch 2 taken 1674 times.
✓ Branch 3 taken 2339 times.
✓ Branch 4 taken 3853 times.
5403 switch(d2)
16792 {
16793 case up:
16794
3/3
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 227 times.
729 switch(shiftdir)
16795 {
16796 case left:
16797 79 dx = -step_diag;
16798
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if (IsSideSwim()) dx = left_step;
16799 79 break;
16800 case right:
16801 227 dx = step_diag;
16802
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 if (IsSideSwim()) dx = right_step;
16803 227 break;
16804 }
16805
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 469 times.
729 if(walkable)
16806 {
16807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (!IsSideSwim()) dy = -step;
16808
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if (IsSideSwim())
16809 {
16810 dy = up_step;
16811 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16812 }
16813 469 }
16814 729 break;
16815 case down:
16816
3/3
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 359 times.
✓ Branch 2 taken 557 times.
1674 switch(shiftdir)
16817 {
16818 case left:
16819 359 dx = -step_diag;
16820
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if (IsSideSwim()) dx = left_step;
16821 359 break;
16822 case right:
16823 557 dx = step_diag;
16824
1/2
✓ Branch 0 taken 557 times.
✗ Branch 1 not taken.
557 if (IsSideSwim()) dx = right_step;
16825 557 break;
16826 }
16827
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 650 times.
1674 if(walkable)
16828 {
16829 650 dy = step;
16830
1/2
✓ Branch 0 taken 650 times.
✗ Branch 1 not taken.
650 if (IsSideSwim()) dy = down_step;
16831 650 }
16832 1674 break;
16833 case left:
16834
3/3
✓ Branch 0 taken 2079 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 90 times.
2339 switch(shiftdir)
16835 {
16836 case up:
16837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if (!IsSideSwim()) dy = -step_diag;
16838
1/2
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
170 if (IsSideSwim())
16839 {
16840 dy = up_step;
16841 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16842 }
16843 170 break;
16844 case down:
16845 90 dy = step_diag;
16846
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if (IsSideSwim()) dy = down_step;
16847 90 break;
16848 }
16849
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 2104 times.
2339 if(walkable)
16850 {
16851 2104 dx = -step;
16852
1/2
✓ Branch 0 taken 2104 times.
✗ Branch 1 not taken.
2104 if (IsSideSwim()) dx = left_step;
16853 2104 }
16854 2339 break;
16855 case right:
16856
3/3
✓ Branch 0 taken 3427 times.
✓ Branch 1 taken 309 times.
✓ Branch 2 taken 117 times.
3853 switch(shiftdir)
16857 {
16858 case up:
16859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
309 if (!IsSideSwim()) dy = -step_diag;
16860
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if (IsSideSwim())
16861 {
16862 dy = up_step;
16863 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16864 }
16865 309 break;
16866 case down:
16867 117 dy = step_diag;
16868
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if (IsSideSwim()) dy = down_step;
16869 117 break;
16870 }
16871
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 3516 times.
3853 if(walkable)
16872 {
16873 3516 dx = step;
16874
1/2
✓ Branch 0 taken 3516 times.
✗ Branch 1 not taken.
3516 if (IsSideSwim()) dx = right_step;
16875 3516 }
16876 3853 break;
16877 };
16878 11787 }
16879 else
16880 {
16881 if(hero_newstep < step) step = hero_newstep; //handle collision
16882 switch(d2)
16883 {
16884 case up:
16885 dy -= step;
16886 if (IsSideSwim()) dy = up_step;
16887 break;
16888 case down:
16889 dy += step;
16890 if (IsSideSwim()) dy = down_step;
16891 break;
16892 case left:
16893 dx -= step;
16894 if (IsSideSwim()) dx = left_step;
16895 break;
16896 case right:
16897 dx += step;
16898 if (IsSideSwim()) dx = right_step;
16899 break;
16900 };
16901 }
16902 11787 hero_newstep = movepix;
16903 11787 hero_newstep_diag = movepix;
16904
16905
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 11787 times.
✓ Branch 2 taken 8595 times.
✓ Branch 3 taken 3192 times.
✓ Branch 4 taken 8595 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8595 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 8595 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
11787 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
16906 {
16907 8595 dir=d2;
16908 8595 }
16909
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 3192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3192 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
16910 {
16911 dir = shiftdir;
16912 }
16913
1/2
✓ Branch 0 taken 11787 times.
✗ Branch 1 not taken.
11787 if(forceRate > -1)
16914 {
16915 checkladder = false;
16916 switch(dir)
16917 {
16918 case right:
16919 case r_up:
16920 case r_down:
16921 dx = zfix(forceRate) / 100;
16922 break;
16923 case left:
16924 case l_up:
16925 case l_down:
16926 dx = zfix(-forceRate) / 100;
16927 break;
16928 default:
16929 dx = 0;
16930 }
16931 switch(dir)
16932 {
16933 case down:
16934 case r_down:
16935 case l_down:
16936 dy = zfix(forceRate) / 100;
16937 break;
16938 case up:
16939 case r_up:
16940 case l_up:
16941 dy = zfix(-forceRate) / 100;
16942 break;
16943 default:
16944 dy = 0;
16945 }
16946 }
16947
4/4
✓ Branch 0 taken 1753 times.
✓ Branch 1 taken 10034 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 922 times.
11787 if(dx == 0 && dy == 0) return;
16948
5/8
✓ Branch 0 taken 7673 times.
✓ Branch 1 taken 3192 times.
✓ Branch 2 taken 7673 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7673 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7673 times.
10865 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16949 {
16950 7673 herostep();
16951
16952 //ack... don't walk if in midair! -DD
16953
10/14
✓ Branch 0 taken 7673 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7673 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7673 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7673 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4274 times.
✓ Branch 9 taken 3399 times.
✓ Branch 10 taken 1621 times.
✓ Branch 11 taken 2653 times.
✓ Branch 12 taken 179 times.
✓ Branch 13 taken 1442 times.
7673 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
16954 {
16955 6231 action=walking; FFCore.setHeroAction(walking);
16956 6231 }
16957
16958
2/2
✓ Branch 0 taken 7280 times.
✓ Branch 1 taken 393 times.
7673 if(++hero_count > (16*hero_animation_speed))
16959 393 hero_count=0;
16960 7673 }
16961
1/2
✓ Branch 0 taken 3192 times.
✗ Branch 1 not taken.
3192 else if(!(frame & 1))
16962 {
16963 herostep();
16964 }
16965
16966
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10865 times.
✓ Branch 2 taken 3192 times.
✓ Branch 3 taken 3192 times.
10865 if(charging==0 || attack!=wHammer)
16967 {
16968 14057 sprite::move(dx, dy);
16969 14057 WalkflagInfo info;
16970 14057 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
16971 14057 execute(info);
16972
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7673 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7673 times.
✗ Branch 7 not taken.
14057 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
16973 {
16974 if (game->get_sideswim_jump() != 0)
16975 {
16976 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
16977 sfx(WAV_ZN1SPLASH,(int32_t)x);
16978 hopclk = 0;
16979 if (charging || spins) action = attacking;
16980 else action = none;
16981 }
16982 else
16983 {
16984 sprite::move(zfix(0), zfix(-1*dy));
16985 }
16986 }
16987 7673 }
16988 50919 }
16989
16990 39132 void HeroClass::moveOld(int32_t d2)
16991 {
16992 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
16993 static bool totalskip = false;
16994
16995
3/6
✓ Branch 0 taken 39132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39132 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 39132 times.
39132 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16996 return;
16997
16998 39132 int32_t dx=0,dy=0;
16999 39132 int32_t xstep=lsteps[x.getInt()&7];
17000 39132 int32_t ystep=lsteps[y.getInt()&7];
17001 39132 int32_t z3skip=0;
17002 39132 int32_t z3diagskip=0;
17003
3/6
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 38791 times.
✓ Branch 2 taken 341 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
77923 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
17004
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38791 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38791 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
17005
1/2
✓ Branch 0 taken 39132 times.
✗ Branch 1 not taken.
39132 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
17006 39132 bool is_swimming = (action == swimming);
17007
17008 //slow walk combo, or charging, moves at 2/3 speed
17009 if(
17010
4/4
✓ Branch 0 taken 38881 times.
✓ Branch 1 taken 251 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 38541 times.
39383 (!is_swimming && (slowcharging ^ slowcombo))||
17011
2/2
✓ Branch 0 taken 251 times.
✓ Branch 1 taken 38541 times.
38792 (is_swimming && (zinit.hero_swim_speed>60))
17012 )
17013 {
17014 591 totalskip = false;
17015
17016
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 292 times.
591 if(diagonalMovement)
17017 {
17018 299 skipstep=(skipstep+1)%6;
17019
17020
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 149 times.
299 if(skipstep%2==0) z3skip=1;
17021 150 else z3skip=0;
17022
17023
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 99 times.
299 if(skipstep%3==0) z3diagskip=1;
17024 200 else z3diagskip=0;
17025 299 }
17026 else
17027 {
17028
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 272 times.
292 if(d2<left)
17029 {
17030
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8 times.
20 if(ystep>1)
17031 {
17032 8 skipstep^=1;
17033 8 ystep=skipstep;
17034 8 }
17035 20 }
17036 else
17037 {
17038
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 109 times.
272 if(xstep>1)
17039 {
17040 109 skipstep^=1;
17041 109 xstep=skipstep;
17042 109 }
17043 }
17044 }
17045 591 }
17046 // else if(is_swimming || (slowcharging && slowcombo))
17047 else if(
17048
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38541 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38541 (is_swimming && (zinit.hero_swim_speed<60))||
17049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38541 times.
38541 (slowcharging && slowcombo)
17050 )
17051 {
17052 //swimming, or charging on a slow combo, moves at 1/2 speed
17053 totalskip = !totalskip;
17054
17055 if(diagonalMovement)
17056 {
17057 skipstep=0;
17058 }
17059 }
17060 else
17061 {
17062 38541 totalskip = false;
17063
17064
2/2
✓ Branch 0 taken 38049 times.
✓ Branch 1 taken 492 times.
38541 if(diagonalMovement)
17065 {
17066 492 skipstep=0;
17067 492 }
17068 }
17069
17070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39132 times.
39132 if(!totalskip)
17071 {
17072
2/2
✓ Branch 0 taken 791 times.
✓ Branch 1 taken 38341 times.
39132 if(diagonalMovement)
17073 {
17074
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 201 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 394 times.
791 switch(d2)
17075 {
17076 case up:
17077
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 65 times.
74 if(shiftdir==left)
17078 {
17079
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(walkable)
17080 {
17081 8 dy-=1-z3diagskip;
17082 8 dx-=1-z3diagskip;
17083 8 z3step=2;
17084 8 }
17085 else
17086 {
17087 1 dx-=1-z3diagskip;
17088 1 z3step=2;
17089 }
17090 9 }
17091
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 55 times.
65 else if(shiftdir==right)
17092 {
17093
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(walkable)
17094 {
17095 10 dy-=1-z3diagskip;
17096 10 dx+=1-z3diagskip;
17097 10 z3step=2;
17098 10 }
17099 else
17100 {
17101 dx+=1-z3diagskip;
17102 z3step=2;
17103 }
17104 10 }
17105 else
17106 {
17107
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 52 times.
55 if(walkable)
17108 {
17109 52 dy-=z3step-z3skip;
17110 52 z3step=(z3step%2)+1;
17111 52 }
17112 }
17113
17114 74 break;
17115
17116 case down:
17117
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 171 times.
201 if(shiftdir==left)
17118 {
17119
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(walkable)
17120 {
17121 30 dy+=1-z3diagskip;
17122 30 dx-=1-z3diagskip;
17123 30 z3step=2;
17124 30 }
17125 else
17126 {
17127 dx-=1-z3diagskip;
17128 z3step=2;
17129 }
17130 30 }
17131
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 132 times.
171 else if(shiftdir==right)
17132 {
17133
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(walkable)
17134 {
17135 39 dy+=1-z3diagskip;
17136 39 dx+=1-z3diagskip;
17137 39 z3step=2;
17138 39 }
17139 else
17140 {
17141 dx+=1-z3diagskip;
17142 z3step=2;
17143 }
17144 39 }
17145 else
17146 {
17147
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 121 times.
132 if(walkable)
17148 {
17149 121 dy+=z3step-z3skip;
17150 121 z3step=(z3step%2)+1;
17151 121 }
17152 }
17153
17154 201 break;
17155
17156 case right:
17157
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 22 times.
122 if(shiftdir==up)
17158 {
17159
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(walkable)
17160 {
17161 22 dy-=1-z3diagskip;
17162 22 dx+=1-z3diagskip;
17163 22 z3step=2;
17164 22 }
17165 else
17166 {
17167 dy-=1-z3diagskip;
17168 z3step=2;
17169 }
17170 22 }
17171
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 98 times.
100 else if(shiftdir==down)
17172 {
17173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(walkable)
17174 {
17175 dy+=1-z3diagskip;
17176 dx+=1-z3diagskip;
17177 z3step=2;
17178 }
17179 else
17180 {
17181 2 dy+=1-z3diagskip;
17182 2 z3step=2;
17183 }
17184 2 }
17185 else
17186 {
17187
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 95 times.
98 if(walkable)
17188 {
17189 95 dx+=z3step-z3skip;
17190 95 z3step=(z3step%2)+1;
17191 95 }
17192 }
17193
17194 122 break;
17195
17196 case left:
17197
2/2
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 136 times.
394 if(shiftdir==up)
17198 {
17199
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 36 times.
136 if(walkable)
17200 {
17201 100 dy-=1-z3diagskip;
17202 100 dx-=1-z3diagskip;
17203 100 z3step=2;
17204 100 }
17205 else
17206 {
17207 36 dy-=1-z3diagskip;
17208 36 z3step=2;
17209 }
17210 136 }
17211
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 218 times.
258 else if(shiftdir==down)
17212 {
17213
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(walkable)
17214 {
17215 40 dy+=1-z3diagskip;
17216 40 dx-=1-z3diagskip;
17217 40 z3step=2;
17218 40 }
17219 else
17220 {
17221 dy+=1-z3diagskip;
17222 z3step=2;
17223 }
17224 40 }
17225 else
17226 {
17227
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 200 times.
218 if(walkable)
17228 {
17229 200 dx-=z3step-z3skip;
17230 200 z3step=(z3step%2)+1;
17231 200 }
17232 }
17233
17234 394 break;
17235 }
17236 791 }
17237 else
17238 {
17239
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9521 times.
✓ Branch 2 taken 5749 times.
✓ Branch 3 taken 10690 times.
✓ Branch 4 taken 12381 times.
38341 switch(d2)
17240 {
17241 case up:
17242
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 9521 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
9521 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
17243
17244 9521 break;
17245
17246 case down:
17247
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 5749 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
5749 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
17248
17249 5749 break;
17250
17251 case left:
17252 10690 dx-=xstep;
17253 10690 break;
17254
17255 case right:
17256 12381 dx+=xstep;
17257 12381 break;
17258 }
17259 }
17260 39132 }
17261
17262
5/16
✗ Branch 0 not taken.
✓ Branch 1 taken 39132 times.
✓ Branch 2 taken 39132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39132 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39132 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 39132 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
39132 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
17263 {
17264 39132 dir=d2;
17265 39132 }
17266 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
17267 {
17268 dir = shiftdir;
17269 }
17270
17271
3/4
✓ Branch 0 taken 38881 times.
✓ Branch 1 taken 251 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38881 times.
39132 if(action != swimming && !IsSideSwim())
17272 {
17273 38881 herostep();
17274
17275 //ack... don't walk if in midair! -DD
17276
5/14
✓ Branch 0 taken 38881 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38881 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38881 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 38881 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 38881 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
38881 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
17277 {
17278 38881 action=walking; FFCore.setHeroAction(walking);
17279 38881 }
17280
17281
2/2
✓ Branch 0 taken 36776 times.
✓ Branch 1 taken 2105 times.
38881 if(++hero_count > (16*hero_animation_speed))
17282 2105 hero_count=0;
17283 38881 }
17284
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 125 times.
251 else if(!(frame & 1))
17285 {
17286 125 herostep();
17287 125 }
17288
17289
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39132 if(charging==0 || attack!=wHammer)
17290 {
17291 39132 sprite::move((zfix)dx,(zfix)dy);
17292 39132 }
17293 39132 }
17294
17295 195004 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
17296 {
17297 195004 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
17298 }
17299 195020 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
17300 {
17301 195020 WalkflagInfo ret;
17302
17303 195020 wx = vbound(wx, -1, 256);
17304 195020 wy = vbound(wy, -1, 176);
17305
17306
7/8
✓ Branch 0 taken 194873 times.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 194646 times.
✓ Branch 3 taken 227 times.
✓ Branch 4 taken 194646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 194634 times.
195020 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
17307 {
17308 386 ret.setUnwalkable(false);
17309 386 return ret;
17310 }
17311
17312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194634 times.
194634 if(toogam)
17313 {
17314 ret.setUnwalkable(false);
17315 return ret;
17316 }
17317
17318
3/4
✓ Branch 0 taken 7295 times.
✓ Branch 1 taken 187339 times.
✓ Branch 2 taken 7295 times.
✗ Branch 3 not taken.
194634 if(blockpath && wy<(bigHitbox?80:88))
17319 {
17320 ret.setUnwalkable(true);
17321 return ret;
17322 }
17323
17324
4/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 194255 times.
✓ Branch 2 taken 267 times.
✓ Branch 3 taken 112 times.
194634 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
17325 {
17326 112 ret.setUnwalkable(true);
17327 112 return ret;
17328 }
17329
17330
2/2
✓ Branch 0 taken 6265 times.
✓ Branch 1 taken 188257 times.
194522 if (collide_object(wx, wy,1, 1))
17331 {
17332 6265 ret.setUnwalkable(true);
17333 6265 return ret;
17334 }
17335
17336
14/20
✓ Branch 0 taken 102415 times.
✓ Branch 1 taken 85842 times.
✓ Branch 2 taken 100316 times.
✓ Branch 3 taken 2099 times.
✓ Branch 4 taken 96272 times.
✓ Branch 5 taken 4044 times.
✓ Branch 6 taken 4044 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 4044 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 2819 times.
✓ Branch 13 taken 1225 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1225 times.
✓ Branch 16 taken 1225 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 486 times.
✓ Branch 19 taken 187771 times.
191433 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17337
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 868 times.
4044 && !get_bit(quest_rules,qr_FREEFORM))
17338 {
17339 486 ret.setUnwalkable(true);
17340 486 return ret;
17341 }
17342
17343
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 187755 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 187755 times.
187771 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
17344
17345
6/6
✓ Branch 0 taken 101929 times.
✓ Branch 1 taken 85842 times.
✓ Branch 2 taken 99830 times.
✓ Branch 3 taken 2099 times.
✓ Branch 4 taken 52538 times.
✓ Branch 5 taken 47292 times.
187771 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
17346 {
17347
2/4
✓ Branch 0 taken 47292 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47292 times.
47292 if((diagonalMovement||NO_GRIDLOCK))
17348 {
17349 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
17350
17351 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
17352 }
17353 47292 }
17354 //All problems related to exiting water are probably here. -Z
17355
3/4
✓ Branch 0 taken 186704 times.
✓ Branch 1 taken 1067 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 186704 times.
187771 if(action==swimming || IsSideSwim())
17356 {
17357
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 746 times.
1067 if(!wf)
17358 {
17359 746 bool isthissolid = false;
17360
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 746 times.
✓ Branch 4 taken 746 times.
✗ Branch 5 not taken.
1492 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17361
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 746 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 746 times.
746 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17362
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 746 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 746 times.
746 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17363
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 746 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 746 times.
746 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
17364 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17365
17366
17367
3/6
✓ Branch 0 taken 746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 746 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 746 times.
746 if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
17368 : (!diagonalMovement) ? 1 : (get_bit(quest_rules,qr_NO_HOPPING)?1:22)))
17369 {
17370 //Check for out of bounds for swimming
17371 bool changehop = true;
17372
17373 if((diagonalMovement||NO_GRIDLOCK))
17374 {
17375 if(wx<0||wy<0)
17376 changehop = false;
17377 else if(wx>248)
17378 changehop = false;
17379 else if(wx>240&&cnt==2)
17380 changehop = false;
17381 else if(wy>168)
17382 changehop = false;
17383 }
17384 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
17385 //This may be where the hang-up for exiting water exists. -Z
17386 // hop out of the water
17387 if(changehop)
17388 ret.setHopClk(1);
17389 }
17390 else
17391 {
17392
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 746 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
746 if((!(get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
17393 {
17394 //int32_t vx=((int32_t)x+4)&0xFFF8;
17395 //int32_t vy=((int32_t)y+4)&0xFFF8;
17396 if(d2==left)
17397 {
17398 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
17399 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
17400 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17401 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17402 {
17403 ret.setHopDir(d2);
17404 ret.setIlswim(true);
17405 }
17406 else ret.setIlswim(false);
17407 }
17408 else if(d2==right)
17409 {
17410 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
17411 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
17412 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17413 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17414 {
17415 ret.setHopDir(d2);
17416 ret.setIlswim(true);
17417 }
17418 else ret.setIlswim(false);
17419 }
17420 else if(d2==up)
17421 {
17422 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
17423 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
17424 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17425 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17426 {
17427 ret.setHopDir(d2);
17428 ret.setIlswim(true);
17429 }
17430 else ret.setIlswim(false);
17431 }
17432 else if(d2==down)
17433 {
17434 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
17435 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
17436 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
17437 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
17438 {
17439 ret.setHopDir(d2);
17440 ret.setIlswim(true);
17441 }
17442 else ret.setIlswim(false);
17443 }
17444 }
17445
17446
2/4
✓ Branch 0 taken 746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 746 times.
746 if(wx<0||wy<0);
17447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
746 else if(wx>248);
17448
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
746 else if(wx>240&&cnt==2);
17449
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 738 times.
746 else if(wy>168);
17450
2/4
✓ Branch 0 taken 738 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 738 times.
738 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
17451 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
17452 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17453 {
17454 ret.setUnwalkable(false);
17455 return ret;
17456 }
17457 else
17458 {
17459 ret.setUnwalkable(true);
17460 return ret;
17461 }
17462 }
17463 746 }
17464 else
17465 {
17466 321 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17467 321 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
17468
17469
8/8
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 252 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 268 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 37 times.
321 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17470 {
17471 16 ret.setUnwalkable(false);
17472 16 return ret;
17473 }
17474 }
17475 1051 }
17476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186704 times.
186704 else if(ladderx+laddery) // ladder is being used
17477 {
17478 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
17479 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
17480
17481 if((diagonalMovement||NO_GRIDLOCK))
17482 {
17483 if(ladderdir==up)
17484 {
17485 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17486 {
17487 bool temp = false;
17488
17489 if(!(abs(lx-(ladderx+8))<=8))
17490 temp = true;
17491
17492 if(cnt==2)
17493 if(!(abs((lx+8)-(ladderx+8))<=8))
17494 temp=true;
17495
17496 if(!temp)
17497 {
17498 ret.setUnwalkable(false);
17499 return ret;
17500 }
17501
17502 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17503 {
17504 ret.setUnwalkable(true);
17505 return ret;
17506 }
17507 }
17508 }
17509 else
17510 {
17511 if(abs(lx-(ladderx+8))<=8)
17512 {
17513 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17514 {
17515 ret.setUnwalkable(false);
17516 return ret;
17517 }
17518
17519 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17520 {
17521 ret.setUnwalkable(true);
17522 return ret;
17523 }
17524
17525 if((abs(ly-laddery+8)<=8) && d2<=down)
17526 {
17527 ret.setUnwalkable(false);
17528 return ret;
17529 }
17530 }
17531 }
17532 } // diagonalMovement
17533 else
17534 {
17535 if((d2&2)==ladderdir) // same direction
17536 {
17537 switch(d2)
17538 {
17539 case up:
17540 if(y.getInt()<=laddery)
17541 {
17542 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
17543 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
17544 return ret;
17545
17546 }
17547
17548 [[fallthrough]];
17549 case down:
17550 if((wy&0xF0)==laddery)
17551 {
17552 ret.setUnwalkable(false);
17553 return ret;
17554 }
17555
17556 break;
17557
17558 default:
17559 if((wx&0xF0)==ladderx)
17560 {
17561 ret.setUnwalkable(false);
17562 return ret;
17563 }
17564 }
17565
17566 if(d2<=down)
17567 {
17568 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
17569 return ret;
17570 }
17571
17572 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
17573 return ret;
17574 }
17575
17576 // different dir
17577 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
17578 {
17579 ret.setUnwalkable(true);
17580 return ret;
17581 }
17582
17583 if(wy>=laddery && wy<=laddery+16 && d2<=down)
17584 {
17585 ret.setUnwalkable(false);
17586 return ret;
17587 }
17588 }
17589 }
17590
6/6
✓ Branch 0 taken 165105 times.
✓ Branch 1 taken 21599 times.
✓ Branch 2 taken 148342 times.
✓ Branch 3 taken 16763 times.
✓ Branch 4 taken 16935 times.
✓ Branch 5 taken 131407 times.
186704 else if(wf || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
17591 {
17592 // see if it's a good spot for the ladder or for swimming
17593
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55297 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55297 times.
55297 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17594
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55297 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55297 times.
55297 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
17595
17596
2/2
✓ Branch 0 taken 34127 times.
✓ Branch 1 taken 21170 times.
55297 if(get_bit(quest_rules, qr_DROWN))
17597 {
17598 // Drowning changes the following attributes:
17599 // * Dangerous water is also walkable, so ignore the previous
17600 // definitions of unwalkablex and unwalkablex8.
17601 // * Instead, prevent the ladder from being used in the
17602 // one frame where Hero has landed on water before drowning.
17603 34127 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17604 34127 }
17605
17606 // check if he can swim
17607
4/6
✓ Branch 0 taken 1821 times.
✓ Branch 1 taken 53476 times.
✓ Branch 2 taken 1821 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1821 times.
55297 if(current_item(itype_flippers) && z==0 && fakez==0)
17608 {
17609 1821 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17610 1821 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
17611
2/6
✓ Branch 0 taken 1821 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1821 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1821 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17612 {
17613 //ladder ignores water combos that are now walkable thanks to flippers -DD
17614
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1819 times.
1821 unwalkablex = unwalkablex && (!wtrx);
17615
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1819 times.
1821 unwalkablex8 = unwalkablex8 && (!wtrx8);
17616
17617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1821 times.
1821 if(landswim >= 22)
17618 {
17619 ret.setHopClk(2);
17620 ret.setUnwalkable(false);
17621 return ret;
17622 }
17623
7/8
✓ Branch 0 taken 1168 times.
✓ Branch 1 taken 653 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1168 times.
✓ Branch 4 taken 653 times.
✓ Branch 5 taken 1168 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 646 times.
1821 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17624 {
17625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if(!(diagonalMovement||NO_GRIDLOCK))
17626 {
17627 ret.setHopClk(2);
17628
17629 if(charging || spins>5)
17630 {
17631 //if Hero is charging, he might be facing the wrong direction (we want him to
17632 //hop into the water, not in the facing direction)
17633 ret.setDir(d2);
17634 //moreover Hero can't charge in the water -DD
17635 ret.setChargeAttack();
17636 }
17637
17638 ret.setUnwalkable(false);
17639 return ret;
17640 }
17641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 else if(dir==d2)
17642 {
17643 7 ret.setIlswim(true);
17644 7 ladderx = 0;
17645 7 laddery = 0;
17646 7 }
17647 7 }
17648 1821 }
17649 1821 }
17650
17651 // check if he can use the ladder
17652 // "Allow Ladder Anywhere" is toggled by fLADDER
17653
2/2
✓ Branch 0 taken 54270 times.
✓ Branch 1 taken 1027 times.
55297 if(can_deploy_ladder())
17654 // laddersetup
17655 {
17656 // Check if there's water to use the ladder over
17657 1027 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
17658 1027 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
17659 1027 int32_t ldrid = current_item_id(itype_ladder);
17660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17661
17662
2/4
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1027 times.
1027 if(wtrx || wtrx8)
17663 {
17664 if(isSideViewHero())
17665 {
17666 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17667 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17668 }
17669 // * walk on half-water using the ladder instead of using flippers.
17670 // * otherwise, walk on ladder(+hookshot) combos.
17671 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
17672 {
17673 if(!get_bit(quest_rules, qr_OLD_210_WATER))
17674 {
17675 //if Hero could swim on a tile instead of using the ladder,
17676 //refuse to use the ladder to step over that tile. -DD
17677 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
17678 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
17679 }
17680 }
17681 }
17682 else
17683 {
17684 // No water; check other things
17685
17686 //Check pits
17687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 if(ladderpits)
17688 {
17689 1027 int32_t pit_cmb = getpitfall(wx,wy);
17690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17691 1027 pit_cmb = getpitfall(x+8,wy);
17692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17693 1027 }
17694
3/6
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
1027 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
17695 {
17696 1027 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
17697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17698 1027 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
17699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17700 1027 }
17701 }
17702
17703
2/2
✓ Branch 0 taken 2054 times.
✓ Branch 1 taken 1027 times.
3081 for (int32_t i = 0; i <= 1; ++i)
17704 {
17705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
2054 if(tmpscr2[i].valid!=0)
17706 {
17707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
2054 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
17708 {
17709 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17710 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17711 }
17712 else
17713 {
17714
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2054 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17715
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2054 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17716 }
17717 2054 }
17718 2054 }
17719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
17720
17721
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1027 if((diagonalMovement||NO_GRIDLOCK))
17722 {
17723
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 826 times.
1027 if(d2==dir)
17724 {
17725 826 int32_t c = walkwater ? 0:8;
17726 826 int32_t b = walkwater ? 8:0;
17727
17728
2/2
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 143 times.
826 if(d2>=left)
17729 {
17730 // If the difference between wy and y is small enough
17731
3/4
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 492 times.
✓ Branch 2 taken 683 times.
✗ Branch 3 not taken.
683 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
17732 {
17733 // Don't activate the ladder if it would be entirely
17734 // over water and Hero has the flippers. This isn't
17735 // a good way to do this, but it's too risky
17736 // to make big changes to this stuff.
17737 bool deployLadder=true;
17738 int32_t lx=wx&0xF0;
17739 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17740 {
17741 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17742 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17743 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17744 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17745 deployLadder=false;
17746 }
17747 if(deployLadder)
17748 {
17749 ladderx = wx&0xF0;
17750 laddery = y;
17751 ladderdir = left;
17752 ladderstart = d2;
17753 ret.setUnwalkable(laddery!=y.getInt());
17754 return ret;
17755 }
17756 }
17757 683 }
17758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 else if(d2<=down)
17759 {
17760 // If the difference between wx and x is small enough
17761
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 143 times.
143 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
17762 {
17763 ladderx = x;
17764 laddery = wy&0xF0;
17765 ladderdir = up;
17766 ladderstart = d2;
17767 ret.setUnwalkable(ladderx!=x.getInt());
17768 return ret;
17769 }
17770
17771
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 101 times.
143 if(cnt==2)
17772 {
17773
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
101 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
17774 {
17775 ladderx = x;
17776 laddery = wy&0xF0;
17777 ladderdir = up;
17778 ladderstart = d2;
17779 ret.setUnwalkable(ladderx!=x.getInt());
17780 return ret;
17781 }
17782 101 }
17783 143 }
17784 826 }
17785 1027 }
17786 else
17787 {
17788 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
17789 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
17790
17791 if((d2>=left && wtrx)
17792 // Deploy the ladder vertically even if Hero is only half on water.
17793 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
17794 {
17795 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
17796 ladderdir = up;
17797 else
17798 ladderdir = left;
17799
17800 if(ladderdir==up)
17801 {
17802 ladderx = x.getInt()&0xF8;
17803 laddery = wy&0xF0;
17804 }
17805 else
17806 {
17807 ladderx = wx&0xF0;
17808 laddery = y.getInt()&0xF8;
17809 }
17810
17811 ret.setUnwalkable(false);
17812 return ret;
17813 }
17814 }
17815 1027 }
17816 55297 }
17817
17818 187755 ret.setUnwalkable(wf);
17819 187755 return ret;
17820 195004 }
17821
17822 // Only checks for moving blocks. Apparently this is a thing we need.
17823 17948 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
17824 {
17825 17948 HeroClass::WalkflagInfo ret;
17826
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 17917 times.
17948 if (!blockmoving) //Without this, weird swimming behaviors happen.
17827 {
17828 17917 ret.setFlags(~1);
17829 17917 ret.setHopDir(-1);
17830 17917 }
17831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17948 times.
17948 if(toogam) return ret;
17832
2/2
✓ Branch 0 taken 17917 times.
✓ Branch 1 taken 31 times.
17948 if (blockmoving)
17833 31 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
17834
2/2
✓ Branch 0 taken 17616 times.
✓ Branch 1 taken 332 times.
17948 if (collide_object(wx, wy,1, 1))
17835 332 ret.setUnwalkable(true);
17836 17948 return ret;
17837 17948 }
17838
17839 77407 bool HeroClass::checksoliddamage()
17840 {
17841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77407 times.
77407 if(toogam) return false;
17842
17843
2/4
✓ Branch 0 taken 77407 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77407 times.
77407 if(z!=0||fakez!=0) return false;
17844 77407 int32_t bx = x.getInt();
17845 77407 int32_t by = y.getInt();
17846 77407 int32_t initk = 0;
17847
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 19540 times.
✓ Branch 2 taken 11098 times.
✓ Branch 3 taken 19648 times.
✓ Branch 4 taken 27121 times.
77407 switch(dir)
17848 {
17849 case up:
17850
17851 19540 by-=bigHitbox ? 4 : -4;
17852
17853
1/2
✓ Branch 0 taken 19540 times.
✗ Branch 1 not taken.
19540 if(by<0)
17854 {
17855 return false;
17856 }
17857 19540 break;
17858
17859 case down:
17860
17861 11098 by+=20;
17862
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 11024 times.
11098 if(by>175)
17863 {
17864 74 return false;
17865 }
17866
17867 11024 break;
17868
17869 case left:
17870 19648 bx-=4;
17871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19648 times.
19648 if (!bigHitbox)
17872 {
17873 19648 by+=8;
17874 19648 initk = 1;
17875 19648 }
17876
2/2
✓ Branch 0 taken 19548 times.
✓ Branch 1 taken 100 times.
19648 if(bx<0)
17877 {
17878 100 return false;
17879 }
17880
17881 19548 break;
17882
17883 case right:
17884
17885 27121 bx+=20;
17886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27121 times.
27121 if (!bigHitbox)
17887 {
17888 27121 by+=8;
17889 27121 initk = 1;
17890 27121 }
17891
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 26967 times.
27121 if(bx>255)
17892 {
17893 154 return false;
17894 }
17895
17896 26967 break;
17897 }
17898 77079 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
17899 77079 int32_t t = cmb.type;
17900
1/2
✓ Branch 0 taken 77079 times.
✗ Branch 1 not taken.
77079 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17901 t = cNONE;
17902 77079 int32_t initbx = bx;
17903 77079 int32_t initby = by;
17904
17905 // Unlike push blocks, damage combos should be tested on layers 2 and under
17906
2/2
✓ Branch 0 taken 166889 times.
✓ Branch 1 taken 77076 times.
243965 for(int32_t i=(get_bit(quest_rules,qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
17907 {
17908 166889 bx = initbx;
17909 166889 by = initby;
17910
2/2
✓ Branch 0 taken 400703 times.
✓ Branch 1 taken 166886 times.
567589 for (int32_t k = initk; k <= 2; k++)
17911 {
17912 400703 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
17913 400703 t = cmb.type;
17914
1/2
✓ Branch 0 taken 400703 times.
✗ Branch 1 not taken.
400703 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17915 t = cNONE;
17916 // Solid damage combos use pushing>0, hence the code is here.
17917
10/10
✓ Branch 0 taken 71634 times.
✓ Branch 1 taken 329069 times.
✓ Branch 2 taken 28221 times.
✓ Branch 3 taken 43413 times.
✓ Branch 4 taken 25431 times.
✓ Branch 5 taken 2790 times.
✓ Branch 6 taken 954 times.
✓ Branch 7 taken 24477 times.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 936 times.
400703 if (!get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
17918 {
17919
2/18
✓ Branch 0 taken 396977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 396977 times.
✗ Branch 17 not taken.
396977 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting && !get_bit(quest_rules, qr_NOSOLIDDAMAGECOMBOS))
17920 {
17921 // Bite Hero
17922 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
17923 }
17924 396977 }
17925
3/4
✓ Branch 0 taken 28221 times.
✓ Branch 1 taken 372482 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27489 times.
428192 if(isSideViewHero() && // Check for sideview damage combos
17926
3/4
✓ Branch 0 taken 27489 times.
✓ Branch 1 taken 732 times.
✓ Branch 2 taken 27489 times.
✗ Branch 3 not taken.
28221 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
17927 {
17928
1/2
✓ Branch 0 taken 27489 times.
✗ Branch 1 not taken.
27489 if (get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES))
17929 {
17930
4/6
✓ Branch 0 taken 27489 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 27471 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
27489 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
17931 {
17932
4/4
✓ Branch 0 taken 27468 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 27468 times.
✓ Branch 3 taken 3 times.
27471 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
17933 {
17934
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
17935 }
17936 27468 }
17937
1/2
✓ Branch 0 taken 27486 times.
✗ Branch 1 not taken.
27486 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
17938 27486 }
17939 else
17940 {
17941 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
17942 if ( get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES ) )
17943 {
17944 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
17945 x+8+(zc_max(tmpscr->csensitive-1,0)),
17946 y+17-(get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
17947 y+17+zc_max((get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
17948 return true;
17949 }
17950 else //2.50.1 and later
17951 {
17952 if(checkdamagecombos(x+4, x+12, y+16, y+24))
17953 return true;
17954 }
17955 }
17956
17957 27486 }
17958
2/2
✓ Branch 0 taken 200784 times.
✓ Branch 1 taken 199916 times.
400700 if (dir < left) bx += (k % 2) ? 7 : 8;
17959 199916 else by += (k % 2) ? 7 : 8;
17960 400700 }
17961 166886 }
17962 77076 return false;
17963 77407 }
17964 79833 void HeroClass::checkpushblock()
17965 {
17966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79833 times.
79833 if(toogam) return;
17967
17968
2/4
✓ Branch 0 taken 79833 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79833 times.
79833 if(z!=0||fakez!=0) return;
17969
17970 // Return early in some cases..
17971 79833 bool earlyReturn=false;
17972
17973
4/4
✓ Branch 0 taken 65186 times.
✓ Branch 1 taken 14647 times.
✓ Branch 2 taken 69342 times.
✓ Branch 3 taken 10491 times.
79833 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
17974
2/2
✓ Branch 0 taken 23035 times.
✓ Branch 1 taken 46307 times.
69342 if(x.getInt()&15) earlyReturn=true;
17975
17976 // if(y<16) return;
17977
4/4
✓ Branch 0 taken 6945 times.
✓ Branch 1 taken 72888 times.
✓ Branch 2 taken 4519 times.
✓ Branch 3 taken 2426 times.
79833 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
17978
17979 77407 int32_t bx = x.getInt()&0xF0;
17980 77407 int32_t by = (y.getInt()&0xF0);
17981
17982
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 19540 times.
✓ Branch 2 taken 11098 times.
✓ Branch 3 taken 19648 times.
✓ Branch 4 taken 27121 times.
77407 switch(dir)
17983 {
17984 case up:
17985
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 19030 times.
19540 if(y<16)
17986 {
17987 510 earlyReturn=true;
17988 510 break;
17989 }
17990
17991
3/4
✓ Branch 0 taken 4522 times.
✓ Branch 1 taken 14508 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4522 times.
19030 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
17992
17993
2/2
✓ Branch 0 taken 11515 times.
✓ Branch 1 taken 7515 times.
19030 if((int32_t)x&8) bx+=16;
17994
17995 19030 break;
17996
17997 case down:
17998
2/2
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 10611 times.
11098 if(y>128)
17999 {
18000 487 earlyReturn=true;
18001 487 break;
18002 }
18003 else
18004 {
18005 10611 by+=16;
18006
18007
2/2
✓ Branch 0 taken 7001 times.
✓ Branch 1 taken 3610 times.
10611 if((int32_t)x&8) bx+=16;
18008 }
18009
18010 10611 break;
18011
18012 case left:
18013
2/2
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 18744 times.
19648 if(x<32)
18014 {
18015 904 earlyReturn=true;
18016 904 break;
18017 }
18018 else
18019 {
18020 18744 bx-=16;
18021
18022
2/2
✓ Branch 0 taken 11618 times.
✓ Branch 1 taken 7126 times.
18744 if(y.getInt()&8)
18023 {
18024 7126 by+=16;
18025 7126 }
18026 }
18027
18028 18744 break;
18029
18030 case right:
18031
2/2
✓ Branch 0 taken 1323 times.
✓ Branch 1 taken 25798 times.
27121 if(x>208)
18032 {
18033 1323 earlyReturn=true;
18034 1323 break;
18035 }
18036 else
18037 {
18038 25798 bx+=16;
18039
18040
2/2
✓ Branch 0 taken 17057 times.
✓ Branch 1 taken 8741 times.
25798 if(y.getInt()&8)
18041 {
18042 8741 by+=16;
18043 8741 }
18044 }
18045
18046 25798 break;
18047 }
18048
18049
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 77404 times.
77407 if (checksoliddamage()) return;
18050
18051
2/2
✓ Branch 0 taken 46514 times.
✓ Branch 1 taken 30890 times.
77404 if(earlyReturn)
18052 46514 return;
18053
18054 30890 int32_t itemid=current_item_id(itype_bracelet);
18055 30890 size_t combopos = (by&0xF0)+(bx>>4);
18056
2/2
✓ Branch 0 taken 30490 times.
✓ Branch 1 taken 400 times.
30890 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
18057
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 30490 times.
30890 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
18058
2/2
✓ Branch 0 taken 13757 times.
✓ Branch 1 taken 57594 times.
71351 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
18059 {
18060
4/4
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 34069 times.
✓ Branch 2 taken 6123 times.
✓ Branch 3 taken 17402 times.
57594 if(get_bit(quest_rules,qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
18061
4/4
✓ Branch 0 taken 26976 times.
✓ Branch 1 taken 13216 times.
✓ Branch 2 taken 24650 times.
✓ Branch 3 taken 2326 times.
40192 if(lyr && !get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
18062 24650 continue;
18063 15542 mapscr* m = FFCore.tempScreens[lyr];
18064 15542 int32_t f = MAPFLAG2(lyr-1,bx,by);
18065 15542 int32_t f2 = MAPCOMBOFLAG2(lyr-1,bx,by);
18066 15542 int32_t t = combobuf[MAPCOMBOL(lyr,bx,by)].type;
18067
2/2
✓ Branch 0 taken 2054 times.
✓ Branch 1 taken 13488 times.
15542 if (lyr == 0) t = combobuf[MAPCOMBO(bx,by)].type;
18068
18069
7/8
✓ Branch 0 taken 15132 times.
✓ Branch 1 taken 410 times.
✓ Branch 2 taken 15132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 256 times.
✓ Branch 5 taken 14466 times.
✓ Branch 6 taken 15015 times.
✓ Branch 7 taken 15271 times.
15542 if((t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) && (pushing<16 || hasMainGuy())) continue;
18070
18071
7/8
✓ Branch 0 taken 15265 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 15138 times.
✓ Branch 3 taken 127 times.
✓ Branch 4 taken 15138 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127 times.
✓ Branch 7 taken 15144 times.
15398 if((t==cPUSH_HW || t==cPUSH_HEAVY || t==cPUSH_HEAVY2 || t==cPUSH_HW2)
18072
3/8
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 15144 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15271 && (itemid<0 || glove->power<((t==cPUSH_HEAVY2 || t==cPUSH_HW2)?2:1) ||
18073
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
127 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
18074
18075 15144 bool doit=false;
18076 15144 bool changeflag=false;
18077 15144 bool changecombo=false;
18078
18079
6/8
✓ Branch 0 taken 15138 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 15141 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15135 times.
30279 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
18080
3/4
✓ Branch 0 taken 15138 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15141 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
18081
3/4
✓ Branch 0 taken 15138 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15141 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
18082
3/4
✓ Branch 0 taken 15138 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15141 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
18083
3/4
✓ Branch 0 taken 15138 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15141 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
18084
3/4
✓ Branch 0 taken 15138 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15141 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
18085
1/2
✓ Branch 0 taken 15135 times.
✗ Branch 1 not taken.
15135 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
18086 {
18087 3 changeflag=true;
18088 3 doit=true;
18089 3 }
18090
18091
4/8
✓ Branch 0 taken 15138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15138 times.
✓ Branch 6 taken 15138 times.
✗ Branch 7 not taken.
30276 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
18092
2/4
✓ Branch 0 taken 15138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15138 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
18093
2/4
✓ Branch 0 taken 15138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15138 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
18094
2/4
✓ Branch 0 taken 15138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15138 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
18095
2/4
✓ Branch 0 taken 15138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15138 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
18096
2/4
✓ Branch 0 taken 15138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15138 times.
✗ Branch 3 not taken.
15138 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
18097
1/2
✓ Branch 0 taken 15138 times.
✗ Branch 1 not taken.
15138 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
18098 {
18099 changecombo=true;
18100 doit=true;
18101 }
18102
18103
2/2
✓ Branch 0 taken 4179 times.
✓ Branch 1 taken 10959 times.
15138 if(get_bit(quest_rules,qr_SOLIDBLK))
18104 {
18105
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 889 times.
✓ Branch 2 taken 1712 times.
✓ Branch 3 taken 377 times.
✓ Branch 4 taken 1201 times.
4179 switch(dir)
18106 {
18107 case up:
18108
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 889 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 889 times.
✓ Branch 4 taken 242 times.
✓ Branch 5 taken 647 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 647 times.
✓ Branch 8 taken 242 times.
✓ Branch 9 taken 647 times.
889 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
18109
18110 889 break;
18111
18112 case down:
18113
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1712 times.
✓ Branch 4 taken 726 times.
✓ Branch 5 taken 986 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 986 times.
✓ Branch 8 taken 726 times.
✓ Branch 9 taken 986 times.
1712 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
18114
18115 1712 break;
18116
18117 case left:
18118
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 377 times.
✓ Branch 4 taken 142 times.
✓ Branch 5 taken 235 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 235 times.
✓ Branch 8 taken 142 times.
✓ Branch 9 taken 235 times.
377 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
18119
18120 377 break;
18121
18122 case right:
18123
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1201 times.
✓ Branch 4 taken 291 times.
✓ Branch 5 taken 910 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 910 times.
✓ Branch 8 taken 291 times.
✓ Branch 9 taken 910 times.
1201 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
18124
18125 1201 break;
18126 }
18127 4179 }
18128
18129
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6478 times.
✓ Branch 2 taken 4249 times.
✓ Branch 3 taken 1291 times.
✓ Branch 4 taken 3120 times.
15138 switch(dir)
18130 {
18131 case up:
18132
2/4
✓ Branch 0 taken 6478 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6478 times.
6478 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
18133
18134 6478 break;
18135
18136 case down:
18137
2/4
✓ Branch 0 taken 4249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4249 times.
4249 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
18138
18139 4249 break;
18140
18141 case left:
18142
2/4
✓ Branch 0 taken 1291 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1291 times.
1291 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
18143
18144 1291 break;
18145
18146 case right:
18147
2/4
✓ Branch 0 taken 3120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3120 times.
3120 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
18148
18149 3120 break;
18150 }
18151
18152
2/2
✓ Branch 0 taken 15135 times.
✓ Branch 1 taken 3 times.
15138 if(doit)
18153 {
18154
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(limitedpush)
18155 ++usecounts[itemid];
18156
18157 // for(int32_t i=0; i<1; i++)
18158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!blockmoving)
18159 {
18160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(changeflag)
18161 {
18162 3 m->sflag[combopos]=0;
18163 3 }
18164
18165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(mblock2.clk<=0)
18166 {
18167 3 mblock2.blockLayer = lyr;
18168 3 mblock2.push((zfix)bx,(zfix)by,dir,f);
18169
18170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(get_bit(quest_rules,qr_MORESOUNDS))
18171 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
18172 3 }
18173 3 }
18174 3 break;
18175 }
18176 15135 }
18177 80105 }
18178
18179 8 bool usekey()
18180 {
18181 8 int32_t itemid = current_item_id(itype_magickey);
18182
18183
1/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(itemid<0 ||
18184 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18185 : itemsbuf[itemid].power!=dlevel))
18186 {
18187
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 if(game->lvlkeys[dlevel]!=0)
18188 {
18189 4 game->lvlkeys[dlevel]--;
18190 //run script for level key item
18191 4 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
18192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 for ( int32_t q = 0; q < MAXITEMS; ++q )
18193 {
18194
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 4 times.
340 if ( itemsbuf[q].family == itype_lkey )
18195 {
18196 4 key_item = q; break;
18197 }
18198 336 }
18199
18200
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18201 {
18202 ri = &(itemScriptData[key_item]);
18203 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18204 ri->Clear();
18205 item_doscript[key_item] = 1;
18206 itemscriptInitialised[key_item] = 0;
18207 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18208 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18209 }
18210 4 return true;
18211 }
18212 else
18213 {
18214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(game->get_keys()==0)
18215 {
18216 return false;
18217 }
18218 else
18219 {
18220 //run script for key item
18221 4 int32_t key_item = 0; //current_item_id(itype_key); //not possible
18222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 for ( int32_t q = 0; q < MAXITEMS; ++q )
18223 {
18224
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 4 times.
40 if ( itemsbuf[q].family == itype_key )
18225 {
18226 4 key_item = q; break;
18227 }
18228 36 }
18229 //zprint2("key_item is: %d\n",key_item);
18230 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
18231
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18232 {
18233 ri = &(itemScriptData[key_item]);
18234 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18235 ri->Clear();
18236 item_doscript[key_item] = 1;
18237 itemscriptInitialised[key_item] = 0;
18238 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18239 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18240 }
18241 4 game->change_keys(-1);
18242 }
18243 }
18244 4 }
18245
18246 4 return true;
18247 8 }
18248
18249 bool canUseKey(int32_t num)
18250 {
18251 int32_t itemid = current_item_id(itype_magickey);
18252
18253 if(itemid<0 ||
18254 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18255 : itemsbuf[itemid].power!=dlevel))
18256 {
18257 return game->lvlkeys[dlevel] + game->get_keys() >= num;
18258 }
18259
18260 return true;
18261 }
18262
18263 bool usekey(int32_t num)
18264 {
18265 if(!canUseKey(num)) return false;
18266 for(auto q = 0; q < num; ++q)
18267 {
18268 if(!usekey()) return false; //should never return false here, but, just to be safe....
18269 }
18270 return true;
18271 }
18272
18273
18274 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
18275 {
18276 int32_t mc = (y&0xF0)+(x>>4);
18277 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
18278 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
18279 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
18280 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
18281 return ret;
18282 }
18283
18284 66406 void HeroClass::oldchecklockblock()
18285 {
18286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66406 times.
66406 if(toogam) return;
18287
18288 66406 int32_t bx = x.getInt()&0xF0;
18289 66406 int32_t bx2 = int32_t(x+8)&0xF0;
18290 66406 int32_t by = y.getInt()&0xF0;
18291
18292
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17939 times.
✓ Branch 2 taken 9470 times.
✓ Branch 3 taken 16579 times.
✓ Branch 4 taken 22418 times.
66406 switch(dir)
18293 {
18294 case up:
18295
4/4
✓ Branch 0 taken 3845 times.
✓ Branch 1 taken 14094 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 3806 times.
17939 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18296
18297 17939 break;
18298
18299 case down:
18300 9470 by+=16;
18301 9470 break;
18302
18303 case left:
18304
2/2
✓ Branch 0 taken 7619 times.
✓ Branch 1 taken 8960 times.
16579 if((((int32_t)x)&0x0F)<8)
18305 8960 bx-=16;
18306
18307
2/2
✓ Branch 0 taken 10213 times.
✓ Branch 1 taken 6366 times.
16579 if(y.getInt()&8)
18308 {
18309 6366 by+=16;
18310 6366 }
18311
18312 16579 bx2=bx;
18313 16579 break;
18314
18315 case right:
18316 22418 bx+=16;
18317
18318
2/2
✓ Branch 0 taken 15376 times.
✓ Branch 1 taken 7042 times.
22418 if(y.getInt()&8)
18319 {
18320 7042 by+=16;
18321 7042 }
18322
18323 22418 bx2=bx;
18324 22418 break;
18325 }
18326
18327 66406 bool found1=false;
18328 66406 bool found2=false;
18329 66406 int32_t foundlayer = -1;
18330 66406 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18331 66406 newcombo const& cmb = combobuf[cid1];
18332 66406 newcombo const& cmb2 = combobuf[cid2];
18333 // Layer 0 is overridden by Locked Doors
18334
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 66406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
66406 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
18335 {
18336 found1=true;
18337 foundlayer = 0;
18338 }
18339
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 66406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
66406 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
18340 {
18341 found2=true;
18342 foundlayer = 0;
18343 }
18344
18345
2/2
✓ Branch 0 taken 132812 times.
✓ Branch 1 taken 66406 times.
199218 for (int32_t i = 0; i <= 1; ++i)
18346 {
18347
2/2
✓ Branch 0 taken 119870 times.
✓ Branch 1 taken 12942 times.
132812 if(tmpscr2[i].valid!=0)
18348 {
18349
2/2
✓ Branch 0 taken 11722 times.
✓ Branch 1 taken 1220 times.
12942 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18350 {
18351
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11722 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11722 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18352
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11722 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11722 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18353 11722 }
18354 else
18355 {
18356
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1220 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18357
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1220 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18358 }
18359 12942 }
18360 132812 }
18361
18362
18363 // Layers
18364
2/4
✓ Branch 0 taken 66406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66406 times.
66406 if(!(found1 || found2))
18365 {
18366 66406 foundlayer = -1;
18367
2/2
✓ Branch 0 taken 66406 times.
✓ Branch 1 taken 132812 times.
199218 for(int32_t i=0; i<2; i++)
18368 {
18369 132812 cid1 = MAPCOMBO2(i, bx, by);
18370 132812 cid2 = MAPCOMBO2(i, bx2, by);
18371 132812 newcombo const& cmb = combobuf[cid1];
18372 132812 newcombo const& cmb2 = combobuf[cid2];
18373
2/2
✓ Branch 0 taken 66406 times.
✓ Branch 1 taken 66406 times.
132812 if (i == 0)
18374 {
18375
1/2
✓ Branch 0 taken 66406 times.
✗ Branch 1 not taken.
66406 if(tmpscr2[1].valid!=0)
18376 {
18377 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18378 {
18379 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
18380 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
18381 }
18382 else
18383 {
18384 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18385 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18386 }
18387 }
18388 66406 }
18389
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 132812 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
132812 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18390 {
18391 found1=true;
18392 foundlayer = i+1;
18393 //zprint("Found layer: %d \n", i);
18394 break;
18395 }
18396
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 132812 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
132812 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
18397 {
18398 found2=true;
18399 foundlayer = i+1;
18400 //zprint("Found layer: %d \n", i);
18401 break;
18402 }
18403 132812 }
18404 66406 }
18405
18406
2/4
✓ Branch 0 taken 66406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66406 times.
✗ Branch 3 not taken.
66406 if(!(found1 || found2) || pushing<8)
18407 {
18408 66406 return;
18409 }
18410 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
18411 if(!try_locked_combo(cmb3))
18412 return;
18413
18414 if(cmb.usrflags&cflag16)
18415 {
18416 setxmapflag(1<<cmb.attribytes[5]);
18417 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18418 }
18419 else
18420 {
18421 setmapflag(mLOCKBLOCK);
18422 remove_lockblocks((currscr>=128)?1:0);
18423 }
18424 if ( cmb3.usrflags&cflag3 )
18425 {
18426 if ( (cmb3.attribytes[3]) )
18427 sfx(cmb3.attribytes[3]);
18428 }
18429 else sfx(WAV_DOOR);
18430 66406 }
18431
18432 66406 void HeroClass::oldcheckbosslockblock()
18433 {
18434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66406 times.
66406 if(toogam) return;
18435
18436 66406 int32_t bx = x.getInt()&0xF0;
18437 66406 int32_t bx2 = int32_t(x+8)&0xF0;
18438 66406 int32_t by = y.getInt()&0xF0;
18439
18440
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17939 times.
✓ Branch 2 taken 9470 times.
✓ Branch 3 taken 16579 times.
✓ Branch 4 taken 22418 times.
66406 switch(dir)
18441 {
18442 case up:
18443
4/4
✓ Branch 0 taken 3845 times.
✓ Branch 1 taken 14094 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 3806 times.
17939 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18444
18445 17939 break;
18446
18447 case down:
18448 9470 by+=16;
18449 9470 break;
18450
18451 case left:
18452
2/2
✓ Branch 0 taken 7619 times.
✓ Branch 1 taken 8960 times.
16579 if((((int32_t)x)&0x0F)<8)
18453 8960 bx-=16;
18454
18455
2/2
✓ Branch 0 taken 10213 times.
✓ Branch 1 taken 6366 times.
16579 if(y.getInt()&8)
18456 {
18457 6366 by+=16;
18458 6366 }
18459
18460 16579 bx2=bx;
18461 16579 break;
18462
18463 case right:
18464 22418 bx+=16;
18465
18466
2/2
✓ Branch 0 taken 15376 times.
✓ Branch 1 taken 7042 times.
22418 if(y.getInt()&8)
18467 {
18468 7042 by+=16;
18469 7042 }
18470
18471 22418 bx2=bx;
18472 22418 break;
18473 }
18474
18475
18476 66406 bool found1 = false;
18477 66406 bool found2 = false;
18478 66406 int32_t foundlayer = -1;
18479 66406 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18480 66406 newcombo const& cmb = combobuf[cid1];
18481 66406 newcombo const& cmb2 = combobuf[cid2];
18482 // Layer 0 is overridden by Locked Doors
18483
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 66406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
66406 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
18484 {
18485 found1 = true;
18486 foundlayer = 0;
18487 }
18488
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 66406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
66406 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
18489 {
18490 found2 = true;
18491 foundlayer = 0;
18492 }
18493
18494
2/2
✓ Branch 0 taken 132812 times.
✓ Branch 1 taken 66406 times.
199218 for (int32_t i = 0; i <= 1; ++i)
18495 {
18496
2/2
✓ Branch 0 taken 119870 times.
✓ Branch 1 taken 12942 times.
132812 if (tmpscr2[i].valid != 0)
18497 {
18498
2/2
✓ Branch 0 taken 11722 times.
✓ Branch 1 taken 1220 times.
12942 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18499 {
18500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11722 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11722 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18501
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11722 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11722 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18502 11722 }
18503 else
18504 {
18505
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1220 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18506
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1220 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18507 }
18508 12942 }
18509 132812 }
18510
18511
18512 // Layers
18513
2/4
✓ Branch 0 taken 66406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66406 times.
66406 if (!(found1 || found2))
18514 {
18515 66406 foundlayer = -1;
18516
2/2
✓ Branch 0 taken 66406 times.
✓ Branch 1 taken 132812 times.
199218 for (int32_t i = 0; i < 2; i++)
18517 {
18518 132812 cid1 = MAPCOMBO2(i, bx, by);
18519 132812 cid2 = MAPCOMBO2(i, bx2, by);
18520 132812 newcombo const& cmb = combobuf[cid1];
18521 132812 newcombo const& cmb2 = combobuf[cid2];
18522
2/2
✓ Branch 0 taken 66406 times.
✓ Branch 1 taken 66406 times.
132812 if (i == 0)
18523 {
18524
1/2
✓ Branch 0 taken 66406 times.
✗ Branch 1 not taken.
66406 if (tmpscr2[1].valid != 0)
18525 {
18526 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18527 {
18528 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18529 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18530 }
18531 else
18532 {
18533 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18534 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18535 }
18536 }
18537 66406 }
18538
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 132812 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
132812 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
18539 {
18540 found1 = true;
18541 foundlayer = i;
18542 break;
18543 }
18544
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 132812 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
132812 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
18545 {
18546 found2 = true;
18547 foundlayer = i;
18548 break;
18549 }
18550 132812 }
18551 66406 }
18552
18553
2/4
✓ Branch 0 taken 66406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66406 times.
✗ Branch 3 not taken.
66406 if (!(found1 || found2) || pushing < 8)
18554 {
18555 66406 return;
18556 }
18557 int32_t cid = found1 ? cid1 : cid2;
18558
18559 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18560
18561
18562 // Run Boss Key Script
18563 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18564 for ( int32_t q = 0; q < MAXITEMS; ++q )
18565 {
18566 if ( itemsbuf[q].family == itype_bosskey )
18567 {
18568 key_item = q; break;
18569 }
18570 }
18571 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18572 {
18573 ri = &(itemScriptData[key_item]);
18574 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18575 ri->Clear();
18576 item_doscript[key_item] = 1;
18577 itemscriptInitialised[key_item] = 0;
18578 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18579 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18580 }
18581
18582 if(cmb.usrflags&cflag16)
18583 {
18584 setxmapflag(1<<cmb.attribytes[5]);
18585 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18586 }
18587 else
18588 {
18589 setmapflag(mBOSSLOCKBLOCK);
18590 remove_bosslockblocks((currscr>=128)?1:0);
18591 }
18592 if ( (combobuf[cid].attribytes[3]) )
18593 sfx(combobuf[cid].attribytes[3]);
18594 66406 }
18595
18596 199218 void HeroClass::oldcheckchest(int32_t type)
18597 {
18598 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
18599
3/6
✓ Branch 0 taken 199218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 199218 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 199218 times.
199218 if(toogam || z>0 || fakez > 0) return;
18600
2/2
✓ Branch 0 taken 192456 times.
✓ Branch 1 taken 6762 times.
199218 if(pushing<8) return;
18601 6762 int32_t bx = x.getInt()&0xF0;
18602 6762 int32_t bx2 = int32_t(x+8)&0xF0;
18603 6762 int32_t by = y.getInt()&0xF0;
18604
18605
3/4
✓ Branch 0 taken 3762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 879 times.
✓ Branch 3 taken 2121 times.
6762 switch(dir)
18606 {
18607 case up:
18608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2121 times.
2121 if(isSideViewHero()) return;
18609
18610
3/4
✓ Branch 0 taken 1107 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 1107 times.
✗ Branch 3 not taken.
2121 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18611
18612 2121 break;
18613
18614 case left:
18615 case right:
18616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3762 times.
3762 if(isSideViewHero()) break;
18617 [[fallthrough]];
18618 case down:
18619 4641 return;
18620 }
18621
18622 2121 bool found=false;
18623 2121 bool itemflag=false;
18624
18625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2121 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2121 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
18626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2121 times.
2121 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
18627 {
18628 found=true;
18629 }
18630
2/2
✓ Branch 0 taken 4242 times.
✓ Branch 1 taken 2121 times.
6363 for (int32_t i = 0; i <= 1; ++i)
18631 {
18632
2/2
✓ Branch 0 taken 4146 times.
✓ Branch 1 taken 96 times.
4242 if(tmpscr2[i].valid!=0)
18633 {
18634
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18635 {
18636
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18638 96 }
18639 else
18640 {
18641 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18642 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18643 }
18644 96 }
18645 4242 }
18646
18647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2121 times.
2121 if(!found)
18648 {
18649
2/2
✓ Branch 0 taken 2121 times.
✓ Branch 1 taken 4242 times.
6363 for(int32_t i=0; i<2; i++)
18650 {
18651
2/2
✓ Branch 0 taken 2121 times.
✓ Branch 1 taken 2121 times.
4242 if (i == 0)
18652 {
18653
1/2
✓ Branch 0 taken 2121 times.
✗ Branch 1 not taken.
2121 if(tmpscr2[1].valid!=0)
18654 {
18655 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18656 {
18657 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18658 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18659 }
18660 else
18661 {
18662 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18663 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18664 }
18665 }
18666 2121 }
18667
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4242 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4242 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
18668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4242 times.
4242 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
18669 {
18670 found=true;
18671 break;
18672 }
18673 4242 }
18674 2121 }
18675
18676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2121 times.
2121 if(!found)
18677 {
18678 2121 return;
18679 }
18680
18681 switch(type)
18682 {
18683 case cLOCKEDCHEST:
18684 if(!usekey()) return;
18685
18686 setmapflag(mLOCKEDCHEST);
18687 break;
18688
18689 case cCHEST:
18690 setmapflag(mCHEST);
18691 break;
18692
18693 case cBOSSCHEST:
18694 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18695 // Run Boss Key Script
18696 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18697 for ( int32_t q = 0; q < MAXITEMS; ++q )
18698 {
18699 if ( itemsbuf[q].family == itype_bosskey )
18700 {
18701 key_item = q; break;
18702 }
18703 }
18704 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18705 {
18706 ri = &(itemScriptData[key_item]);
18707 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18708 ri->Clear();
18709 item_doscript[key_item] = 1;
18710 itemscriptInitialised[key_item] = 0;
18711 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18712 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18713 }
18714 setmapflag(mBOSSCHEST);
18715 break;
18716 }
18717
18718 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18719 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18720 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
18721 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
18722 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18723 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18724
18725 if(!itemflag)
18726 {
18727 for(int32_t i=0; i<2; i++)
18728 {
18729 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
18730 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
18731 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
18732 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
18733 }
18734 }
18735
18736 if(itemflag && !getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
18737 {
18738 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
18739 }
18740 199218 }
18741
18742 67125 void HeroClass::checkchest(int32_t type)
18743 {
18744
4/4
✓ Branch 0 taken 53700 times.
✓ Branch 1 taken 13425 times.
✓ Branch 2 taken 13425 times.
✓ Branch 3 taken 40275 times.
67125 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
18745
2/2
✓ Branch 0 taken 13425 times.
✓ Branch 1 taken 53700 times.
67125 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
18746
2/2
✓ Branch 0 taken 13425 times.
✓ Branch 1 taken 53700 times.
67125 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
18747
2/2
✓ Branch 0 taken 13425 times.
✓ Branch 1 taken 53700 times.
67125 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
18748
2/2
✓ Branch 0 taken 26850 times.
✓ Branch 1 taken 40275 times.
67125 if(ischest)
18749 {
18750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40275 times.
40275 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
18751 {
18752 oldcheckchest(type);
18753 return;
18754 }
18755 40275 }
18756
3/4
✓ Branch 0 taken 26850 times.
✓ Branch 1 taken 40275 times.
✓ Branch 2 taken 26850 times.
✗ Branch 3 not taken.
67125 if(islockblock && get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
18757 {
18758 if(type == cLOCKBLOCK)
18759 oldchecklockblock();
18760 else if(type == cBOSSLOCKBLOCK)
18761 oldcheckbosslockblock();
18762 return;
18763 }
18764
3/6
✓ Branch 0 taken 67125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 67125 times.
67125 if(toogam || z>0 || fakez > 0) return;
18765 67125 zfix bx, by;
18766 67125 zfix bx2, by2;
18767 67125 zfix fx(-1), fy(-1);
18768
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9085 times.
✓ Branch 2 taken 10380 times.
✓ Branch 3 taken 19135 times.
✓ Branch 4 taken 28525 times.
67125 switch(dir)
18769 {
18770 case up:
18771 9085 by = y + (bigHitbox ? -2 : 6);
18772 9085 by2 = by;
18773 9085 bx = x + 4;
18774 9085 bx2 = bx + 8;
18775 9085 break;
18776 case down:
18777 10380 by = y + 17;
18778 10380 by2 = by;
18779 10380 bx = x + 4;
18780 10380 bx2 = bx + 8;
18781 10380 break;
18782 case left:
18783 19135 by = y + (bigHitbox ? 0 : 8);
18784 19135 by2 = y + 8;
18785 19135 bx = x - 2;
18786 19135 bx2 = x - 2;
18787 19135 break;
18788 case right:
18789 28525 by = y + (bigHitbox ? 0 : 8);
18790 28525 by2 = y + 8;
18791 28525 bx = x + 17;
18792 28525 bx2 = x + 17;
18793 28525 break;
18794 }
18795
18796 67125 int32_t found = -1;
18797 67125 int32_t foundlayer = 0;
18798
18799 67125 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
18800
18801
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 67125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
67125 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
18802 {
18803 found = MAPCOMBO(bx,by);
18804 fx = bx; fy = by;
18805 for (int32_t i = 0; i <= 1; ++i)
18806 {
18807 if(tmpscr2[i].valid!=0)
18808 {
18809 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18810 {
18811 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18812 }
18813 else
18814 {
18815 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18816 }
18817 }
18818 }
18819 }
18820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67125 times.
67125 if(found<0)
18821 {
18822 67125 cmb = &combobuf[MAPCOMBO(bx2,by2)];
18823
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 67125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
67125 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
18824 {
18825 found = MAPCOMBO(bx2,by2);
18826 for (int32_t i = 0; i <= 6; ++i)
18827 {
18828 if(tmpscr2[i].valid!=0)
18829 {
18830 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18831 {
18832 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
18833 {
18834 found = -1;
18835 break;
18836 }
18837 }
18838 else
18839 {
18840 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
18841 {
18842 found = -1;
18843 break;
18844 }
18845 }
18846 }
18847 }
18848 if(found != -1)
18849 {
18850 fx = bx2; fy = by2;
18851 }
18852 }
18853 67125 }
18854
18855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67125 times.
67125 if(found<0)
18856 {
18857
2/2
✓ Branch 0 taken 67125 times.
✓ Branch 1 taken 402750 times.
469875 for(int32_t i=0; i<6; i++)
18858 {
18859 402750 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
18860
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 402750 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
402750 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18861 {
18862 found = MAPCOMBO2(i,bx,by);
18863 for(int32_t j = i+1; j < 6; ++j)
18864 {
18865 if (tmpscr2[j].valid!=0)
18866 {
18867 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18868 {
18869 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
18870 {
18871 found = -1;
18872 break;
18873 }
18874 }
18875 else
18876 {
18877 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
18878 {
18879 found = -1;
18880 break;
18881 }
18882 }
18883 }
18884 }
18885 if(found>-1)
18886 {
18887 foundlayer = i+1;
18888 fx = bx; fy = by;
18889 break;
18890 }
18891 }
18892 402750 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
18893
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 402750 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
402750 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
18894 {
18895 found = MAPCOMBO2(i,bx2,by2);
18896 for(int32_t j = i+1; j < 6; ++j)
18897 {
18898 if (tmpscr2[j].valid!=0)
18899 {
18900 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18901 {
18902 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
18903 {
18904 found = -1;
18905 break;
18906 }
18907 }
18908 else
18909 {
18910 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
18911 {
18912 found = -1;
18913 break;
18914 }
18915 }
18916 }
18917 }
18918 if(found>-1)
18919 {
18920 foundlayer = i+1;
18921 fx = bx2; fy = by2;
18922 break;
18923 }
18924 }
18925 402750 }
18926 67125 }
18927
18928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67125 times.
67125 if(found<0) return;
18929 cmb = &combobuf[found];
18930 switch(dir)
18931 {
18932 case up:
18933 if(cmb->usrflags&cflag10)
18934 return;
18935 break;
18936 case down:
18937 if(cmb->usrflags&cflag9)
18938 return;
18939 break;
18940 case left:
18941 if(cmb->usrflags&cflag12)
18942 return;
18943 break;
18944 case right:
18945 if(cmb->usrflags&cflag11)
18946 return;
18947 break;
18948 }
18949 int32_t intbtn = cmb->attribytes[2];
18950
18951 if(intbtn) //
18952 {
18953 if(cmb->usrflags & cflag13) //display prompt
18954 {
18955 int altcmb = cmb->attributes[2]/10000;
18956 prompt_combo = cmb->attributes[1]/10000;
18957 if(altcmb && ((islocked && !can_locked_combo(*cmb))
18958 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
18959 prompt_combo = altcmb;
18960 prompt_cset = cmb->attribytes[4];
18961 prompt_x = cmb->attrishorts[0];
18962 prompt_y = cmb->attrishorts[1];
18963 }
18964 if(!getIntBtnInput(intbtn, true, true, false, false))
18965 {
18966 return; //Button not pressed
18967 }
18968 }
18969 else if(pushing < 8) return; //Not pushing against chest enough
18970
18971 if(ischest)
18972 {
18973 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
18974 }
18975 else if(islockblock)
18976 {
18977 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
18978 }
18979 if(intbtn && (cmb->usrflags & cflag13))
18980 prompt_combo = 0;
18981 67125 }
18982
18983 79964 void HeroClass::checkgenpush()
18984 {
18985
4/4
✓ Branch 0 taken 3766 times.
✓ Branch 1 taken 76198 times.
✓ Branch 2 taken 3214 times.
✓ Branch 3 taken 552 times.
79964 if(pushing < 8 || pushing % 8) return;
18986 552 zfix bx, by;
18987 552 zfix bx2, by2;
18988
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 162 times.
552 switch(dir)
18989 {
18990 case up:
18991 141 by = y + (bigHitbox ? -2 : 6);
18992 141 by2 = by;
18993 141 bx = x + 4;
18994 141 bx2 = bx + 8;
18995 141 break;
18996 case down:
18997 164 by = y + 17;
18998 164 by2 = by;
18999 164 bx = x + 4;
19000 164 bx2 = bx + 8;
19001 164 break;
19002 case left:
19003 85 by = y + (bigHitbox ? 0 : 8);
19004 85 by2 = y + 8;
19005 85 bx = x - 2;
19006 85 bx2 = x - 2;
19007 85 break;
19008 case right:
19009 162 by = y + (bigHitbox ? 0 : 8);
19010 162 by2 = y + 8;
19011 162 bx = x + 17;
19012 162 bx2 = x + 17;
19013 162 break;
19014 }
19015 552 auto pos1 = COMBOPOS(bx,by);
19016 552 auto pos2 = COMBOPOS(bx2,by2);
19017
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 3864 times.
4416 for(auto layer = 0; layer < 7; ++layer)
19018 {
19019 3864 mapscr* tmp = FFCore.tempScreens[layer];
19020
19021 3864 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
19022
1/2
✓ Branch 0 taken 3864 times.
✗ Branch 1 not taken.
3864 if(cmb1.triggerflags[1] & combotriggerPUSH)
19023 do_trigger_combo(layer,pos1);
19024
19025
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 798 times.
3864 if(pos1==pos2) continue;
19026
19027 798 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
19028
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if(cmb2.triggerflags[1] & combotriggerPUSH)
19029 do_trigger_combo(layer,pos2);
19030 798 }
19031
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 348 times.
552 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
19032 {
19033 204 word c = tmpscr->numFFC();
19034
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 1720 times.
1924 for(word i=0; i<c; i++)
19035 {
19036
4/4
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 1605 times.
1720 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
19037 {
19038 115 ffcdata& ffc = tmpscr->ffcs[i];
19039 115 newcombo const& cmb3 = combobuf[ffc.getData()];
19040
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(cmb3.triggerflags[1] & combotriggerPUSH)
19041 {
19042 do_trigger_combo_ffc(i);
19043 break;
19044 }
19045 115 }
19046 1720 }
19047 204 }
19048 79964 }
19049
19050 79964 void HeroClass::checksigns() //Also checks for generic trigger buttons
19051 {
19052
3/6
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79964 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 79964 times.
79964 if(toogam || z>0 || fakez>0) return;
19053
5/6
✓ Branch 0 taken 77977 times.
✓ Branch 1 taken 1987 times.
✓ Branch 2 taken 2198 times.
✓ Branch 3 taken 75779 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2198 times.
79964 if(msg_active || (msg_onscreen && get_bit(quest_rules, qr_MSGDISAPPEAR)))
19054 1987 return; //Don't overwrite a message waiting to be dismissed
19055 77977 zfix bx, by;
19056 77977 zfix bx2, by2;
19057 77977 zfix fx(-1), fy(-1);
19058
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18107 times.
✓ Branch 2 taken 11548 times.
✓ Branch 3 taken 20143 times.
✓ Branch 4 taken 28179 times.
77977 switch(dir)
19059 {
19060 case up:
19061 18107 by = y + (bigHitbox ? -2 : 6);
19062 18107 by2 = by;
19063 18107 bx = x + 4;
19064 18107 bx2 = bx + 8;
19065 18107 break;
19066 case down:
19067 11548 by = y + 17;
19068 11548 by2 = by;
19069 11548 bx = x + 4;
19070 11548 bx2 = bx + 8;
19071 11548 break;
19072 case left:
19073 20143 by = y + (bigHitbox ? 0 : 8);
19074 20143 by2 = y + 8;
19075 20143 bx = x - 2;
19076 20143 bx2 = x - 2;
19077 20143 break;
19078 case right:
19079 28179 by = y + (bigHitbox ? 0 : 8);
19080 28179 by2 = y + 8;
19081 28179 bx = x + 17;
19082 28179 bx2 = x + 17;
19083 28179 break;
19084 }
19085
19086 77977 int32_t found = -1;
19087 77977 int32_t foundffc = -1;
19088 77977 int32_t found_lyr = 0;
19089 77977 bool found_sign = false;
19090 77977 int32_t tmp_cid = MAPCOMBO(bx,by);
19091 77977 newcombo const* tmp_cmb = &combobuf[tmp_cid];
19092
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77977 times.
✓ Branch 2 taken 77977 times.
✗ Branch 3 not taken.
155954 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19093 77977 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
19094 {
19095 found = tmp_cid;
19096 fx = bx; fy = by;
19097 for (int32_t i = 0; i <= 1; ++i)
19098 {
19099 if(tmpscr2[i].valid!=0)
19100 {
19101 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19102 {
19103 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19104 }
19105 else
19106 {
19107 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19108 }
19109 }
19110 }
19111 }
19112 77977 tmp_cid = MAPCOMBO(bx2,by2);
19113 77977 tmp_cmb = &combobuf[tmp_cid];
19114
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77977 times.
✓ Branch 2 taken 77977 times.
✗ Branch 3 not taken.
155954 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19115 77977 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
19116 {
19117 found = tmp_cid;
19118 fx = bx2; fy = by2;
19119 for (int32_t i = 0; i <= 1; ++i)
19120 {
19121 if(tmpscr2[i].valid!=0)
19122 {
19123 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19124 {
19125 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19126 }
19127 else
19128 {
19129 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19130 }
19131 }
19132 }
19133 }
19134
19135
2/2
✓ Branch 0 taken 65043 times.
✓ Branch 1 taken 12934 times.
77977 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
19136 {
19137 12934 word c = tmpscr->numFFC();
19138
2/2
✓ Branch 0 taken 12934 times.
✓ Branch 1 taken 205484 times.
218418 for(word i=0; i<c; i++)
19139 {
19140
4/4
✓ Branch 0 taken 203408 times.
✓ Branch 1 taken 2076 times.
✓ Branch 2 taken 247 times.
✓ Branch 3 taken 203161 times.
205484 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
19141 {
19142 2323 ffcdata& ffc = tmpscr->ffcs[i];
19143 2323 tmp_cmb = &combobuf[ffc.getData()];
19144
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2323 times.
2323 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19145 2323 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
19146 {
19147 foundffc = i;
19148 break;
19149 }
19150 2323 }
19151 205484 }
19152 12934 }
19153
19154
2/4
✓ Branch 0 taken 77977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77977 times.
77977 if(found<0 && foundffc < 0)
19155 {
19156
2/2
✓ Branch 0 taken 77977 times.
✓ Branch 1 taken 467862 times.
545839 for(int32_t i=0; i<6; i++)
19157 {
19158 467862 tmp_cid = MAPCOMBO2(i,bx,by);
19159 467862 tmp_cmb = &combobuf[tmp_cid];
19160
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 467862 times.
✓ Branch 2 taken 467862 times.
✗ Branch 3 not taken.
935724 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19161 467862 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
19162 {
19163 found = tmp_cid;
19164 found_lyr = i+1;
19165 fx = bx; fy = by;
19166 if (i == 0 && tmpscr2[1].valid!=0)
19167 {
19168 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19169 {
19170 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19171 }
19172 else
19173 {
19174 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19175 }
19176 }
19177 }
19178 467862 tmp_cid = MAPCOMBO2(i,bx2,by2);
19179 467862 tmp_cmb = &combobuf[tmp_cid];
19180
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 467862 times.
✓ Branch 2 taken 467862 times.
✗ Branch 3 not taken.
935724 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19181 467862 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
19182 {
19183 found = tmp_cid;
19184 found_lyr = i+1;
19185 fx = bx2; fy = by2;
19186 if (i == 0 && tmpscr2[1].valid!=0)
19187 {
19188 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19189 {
19190 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19191 }
19192 else
19193 {
19194 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19195 }
19196 }
19197 }
19198
1/2
✓ Branch 0 taken 467862 times.
✗ Branch 1 not taken.
467862 if(found>-1) break;
19199 467862 }
19200 77977 }
19201
19202
2/4
✓ Branch 0 taken 77977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77977 times.
77977 if(found<0&&foundffc<0) return;
19203 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
19204
19205 byte signInput = 0;
19206 bool didsign = false;
19207 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
19208 {
19209 switch(dir)
19210 {
19211 case up:
19212 if(cmb.usrflags&cflag10)
19213 goto endsigns;
19214 break;
19215 case down:
19216 if(cmb.usrflags&cflag9)
19217 goto endsigns;
19218 break;
19219 case left:
19220 if(cmb.usrflags&cflag12)
19221 goto endsigns;
19222 break;
19223 case right:
19224 if(cmb.usrflags&cflag11)
19225 goto endsigns;
19226 break;
19227 }
19228 int32_t intbtn = cmb.attribytes[2];
19229
19230 if(intbtn) //
19231 {
19232 signInput = getIntBtnInput(intbtn, true, true, false, false);
19233 if(!signInput)
19234 {
19235 if(cmb.usrflags & cflag13) //display prompt
19236 {
19237 prompt_combo = cmb.attributes[1]/10000;
19238 prompt_cset = cmb.attribytes[4];
19239 prompt_x = cmb.attrishorts[0];
19240 prompt_y = cmb.attrishorts[1];
19241 }
19242 goto endsigns; //Button not pressed
19243 }
19244 }
19245 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
19246
19247 trigger_sign(cmb);
19248 didsign = true;
19249 }
19250 endsigns:
19251 if(!cmb.triggerbtn) return;
19252 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
19253 switch(dir)
19254 {
19255 case down:
19256 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
19257 return;
19258 break;
19259 case up:
19260 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
19261 return;
19262 break;
19263 case right:
19264 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
19265 return;
19266 break;
19267 case left:
19268 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
19269 return;
19270 break;
19271 }
19272 if(getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput))
19273 {
19274 if (foundffc >= 0)
19275 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
19276 else
19277 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
19278 }
19279 else if(cmb.type == cBUTTONPROMPT)
19280 {
19281 prompt_combo = cmb.attributes[0]/10000;
19282 prompt_cset = cmb.attribytes[0];
19283 prompt_x = cmb.attrishorts[0];
19284 prompt_y = cmb.attrishorts[1];
19285 }
19286 else if(cmb.prompt_cid)
19287 {
19288 prompt_combo = cmb.prompt_cid;
19289 prompt_cset = cmb.prompt_cs;
19290 prompt_x = cmb.prompt_x;
19291 prompt_y = cmb.prompt_y;
19292 }
19293 79964 }
19294
19295 79833 void HeroClass::checklocked()
19296 {
19297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79833 times.
79833 if(toogam) return; //Walk through walls.
19298
19299
2/2
✓ Branch 0 taken 41761 times.
✓ Branch 1 taken 38072 times.
79833 if(!isdungeon()) return;
19300
19301
3/4
✓ Branch 0 taken 41761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 41656 times.
41761 if( !diagonalMovement && pushing!=8) return;
19302 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
19303 */
19304
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
19305
19306
19307 105 bool found = false;
19308
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 105 times.
525 for ( int32_t q = 0; q < 4; q++ ) {
19309
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 403 times.
420 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
19310 420 }
19311
19312
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 88 times.
105 if ( !found ) return;
19313
19314 17 int32_t si = (currmap<<7) + currscr;
19315 17 int32_t di = 0;
19316
19317
19318
19319
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
17 if ( diagonalMovement || get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
19320 {
19321 //Up door
19322 if ( y <= 32 && x >= 112 && x <= 128 )
19323 {
19324 if (
19325 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
19326
19327 )
19328 {
19329 di = nextscr(up);
19330 if(tmpscr->door[0]==dLOCKED)
19331 {
19332 if(usekey())
19333 {
19334 putdoor(scrollbuf,0,up,dUNLOCKED);
19335 tmpscr->door[0]=dUNLOCKED;
19336 setmapflag(si, mDOOR_UP);
19337
19338 if(di != 0xFFFF)
19339 setmapflag(di, mDOOR_DOWN);
19340 sfx(WAV_DOOR);
19341 markBmap(-1);
19342 }
19343 else return;
19344 }
19345 else if(tmpscr->door[0]==dBOSS)
19346 {
19347 if(game->lvlitems[dlevel]&liBOSSKEY)
19348 {
19349 putdoor(scrollbuf,0,up,dOPENBOSS);
19350 tmpscr->door[0]=dOPENBOSS;
19351 setmapflag(si, mDOOR_UP);
19352
19353 if(di != 0xFFFF)
19354 setmapflag(di, mDOOR_DOWN);
19355 sfx(WAV_DOOR);
19356 markBmap(-1);
19357 // Run Boss Key Script
19358 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19359 for ( int32_t q = 0; q < MAXITEMS; ++q )
19360 {
19361 if ( itemsbuf[q].family == itype_bosskey )
19362 {
19363 key_item = q; break;
19364 }
19365 }
19366 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19367 {
19368 ri = &(itemScriptData[key_item]);
19369 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19370 ri->Clear();
19371 item_doscript[key_item] = 1;
19372 itemscriptInitialised[key_item] = 0;
19373 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19374 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19375 }
19376 }
19377 else return;
19378
19379 }
19380
19381 }
19382 }
19383 //Down
19384 if ( y >= 128 && x >= 112 && x <= 128 )
19385 {
19386 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
19387 {
19388 di = nextscr(down);
19389 if(tmpscr->door[1]==dLOCKED)
19390 {
19391 if(usekey())
19392 {
19393 putdoor(scrollbuf,0,down,dUNLOCKED);
19394 tmpscr->door[1]=dUNLOCKED;
19395 setmapflag(si, mDOOR_DOWN);
19396
19397 if(di != 0xFFFF)
19398 setmapflag(di, mDOOR_UP);
19399 sfx(WAV_DOOR);
19400 markBmap(-1);
19401 }
19402 else return;
19403 }
19404 else if(tmpscr->door[1]==dBOSS)
19405 {
19406 if(game->lvlitems[dlevel]&liBOSSKEY)
19407 {
19408 putdoor(scrollbuf,0,down,dOPENBOSS);
19409 tmpscr->door[1]=dOPENBOSS;
19410 setmapflag(si, mDOOR_DOWN);
19411
19412 if(di != 0xFFFF)
19413 setmapflag(di, mDOOR_UP);
19414 sfx(WAV_DOOR);
19415 markBmap(-1);
19416 // Run Boss Key Script
19417 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19418 for ( int32_t q = 0; q < MAXITEMS; ++q )
19419 {
19420 if ( itemsbuf[q].family == itype_bosskey )
19421 {
19422 key_item = q; break;
19423 }
19424 }
19425 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19426 {
19427 ri = &(itemScriptData[key_item]);
19428 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19429 ri->Clear();
19430 item_doscript[key_item] = 1;
19431 itemscriptInitialised[key_item] = 0;
19432 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19433 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19434 }
19435 }
19436 else return;
19437 }
19438 }
19439 }
19440 //left
19441 if ( y > 72 && y < 88 && x <= 32 )
19442 {
19443 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
19444 {
19445 di = nextscr(left);
19446 if(tmpscr->door[2]==dLOCKED)
19447 {
19448 if(usekey())
19449 {
19450 putdoor(scrollbuf,0,left,dUNLOCKED);
19451 tmpscr->door[2]=dUNLOCKED;
19452 setmapflag(si, mDOOR_LEFT);
19453
19454 if(di != 0xFFFF)
19455 setmapflag(di, mDOOR_RIGHT);
19456 sfx(WAV_DOOR);
19457 markBmap(-1);
19458 }
19459 else return;
19460 }
19461 else if(tmpscr->door[2]==dBOSS)
19462 {
19463 if(game->lvlitems[dlevel]&liBOSSKEY)
19464 {
19465 putdoor(scrollbuf,0,left,dOPENBOSS);
19466 tmpscr->door[2]=dOPENBOSS;
19467 setmapflag(si, mDOOR_LEFT);
19468
19469 if(di != 0xFFFF)
19470 setmapflag(di, mDOOR_RIGHT);
19471 sfx(WAV_DOOR);
19472 markBmap(-1);
19473 // Run Boss Key Script
19474 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19475 for ( int32_t q = 0; q < MAXITEMS; ++q )
19476 {
19477 if ( itemsbuf[q].family == itype_bosskey )
19478 {
19479 key_item = q; break;
19480 }
19481 }
19482 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19483 {
19484 ri = &(itemScriptData[key_item]);
19485 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19486 ri->Clear();
19487 item_doscript[key_item] = 1;
19488 itemscriptInitialised[key_item] = 0;
19489 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19490 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19491 }
19492 }
19493 else return;
19494 }
19495 }
19496 }
19497
19498
19499 //right
19500 if ( ( y > 72 && y < 88 ) && x >= 208 )
19501 //!( (y<=72||y>=88) && x<206 ) )
19502 //y<=72||y>=88):y!=80) || x<208)
19503 {
19504 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
19505 {
19506 di = nextscr(right);
19507 if(tmpscr->door[right]==dLOCKED)
19508 {
19509 if(usekey())
19510 {
19511 putdoor(scrollbuf,0,right,dUNLOCKED);
19512 tmpscr->door[3]=dUNLOCKED;
19513 setmapflag(si, mDOOR_RIGHT);
19514
19515 if(di != 0xFFFF)
19516 setmapflag(di, mDOOR_LEFT);
19517 sfx(WAV_DOOR);
19518 markBmap(-1);
19519 }
19520 else return;
19521 }
19522 else if(tmpscr->door[right]==dBOSS)
19523 {
19524 if(game->lvlitems[dlevel]&liBOSSKEY)
19525 {
19526 putdoor(scrollbuf,0,right,dOPENBOSS);
19527 tmpscr->door[3]=dOPENBOSS;
19528 setmapflag(si, mDOOR_RIGHT);
19529
19530 if(di != 0xFFFF)
19531 setmapflag(di, mDOOR_LEFT);
19532 sfx(WAV_DOOR);
19533 markBmap(-1);
19534 // Run Boss Key Script
19535 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19536 for ( int32_t q = 0; q < MAXITEMS; ++q )
19537 {
19538 if ( itemsbuf[q].family == itype_bosskey )
19539 {
19540 key_item = q; break;
19541 }
19542 }
19543 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19544 {
19545 ri = &(itemScriptData[key_item]);
19546 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19547 ri->Clear();
19548 item_doscript[key_item] = 1;
19549 itemscriptInitialised[key_item] = 0;
19550 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19551 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19552 }
19553 }
19554 else return;
19555 }
19556
19557 }
19558 }
19559 }
19560 else
19561 {
19562 //orthogonal movement
19563 //Up door
19564
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
17 if ( y<=32 && x == 120 )
19565 //!( y>32 && (x!=120) ))
19566 {
19567
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 switch ( dir )
19568 {
19569 case up:
19570 case r_up:
19571 case l_up:
19572 {
19573 7 di = nextscr(up);
19574
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tmpscr->door[0]==dLOCKED)
19575 {
19576
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(usekey())
19577 {
19578 7 putdoor(scrollbuf,0,up,dUNLOCKED);
19579 7 tmpscr->door[0]=dUNLOCKED;
19580 7 setmapflag(si, mDOOR_UP);
19581
19582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
19583 7 setmapflag(di, mDOOR_DOWN);
19584 7 sfx(WAV_DOOR);
19585 7 markBmap(-1);
19586 7 }
19587 else return;
19588 7 }
19589 else if(tmpscr->door[0]==dBOSS)
19590 {
19591 if(game->lvlitems[dlevel]&liBOSSKEY)
19592 {
19593 putdoor(scrollbuf,0,up,dOPENBOSS);
19594 tmpscr->door[0]=dOPENBOSS;
19595 setmapflag(si, mDOOR_UP);
19596
19597 if(di != 0xFFFF)
19598 setmapflag(di, mDOOR_DOWN);
19599 sfx(WAV_DOOR);
19600 markBmap(-1);
19601 // Run Boss Key Script
19602 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19603 for ( int32_t q = 0; q < MAXITEMS; ++q )
19604 {
19605 if ( itemsbuf[q].family == itype_bosskey )
19606 {
19607 key_item = q; break;
19608 }
19609 }
19610 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19611 {
19612 ri = &(itemScriptData[key_item]);
19613 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19614 ri->Clear();
19615 item_doscript[key_item] = 1;
19616 itemscriptInitialised[key_item] = 0;
19617 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19618 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19619 }
19620 }
19621 else return;
19622 }
19623 7 break;
19624 }
19625 default: break;
19626
19627 }
19628 7 }
19629 //Down
19630
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17 if ( y >= 128 && x == 120 )
19631 //!(y<128 && (x!=120) ) )
19632 {
19633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 switch(dir)
19634 {
19635 case down:
19636 case l_down:
19637 case r_down:
19638 {
19639 di = nextscr(down);
19640
19641 if(tmpscr->door[1]==dLOCKED)
19642 {
19643 if(usekey())
19644 {
19645 putdoor(scrollbuf,0,down,dUNLOCKED);
19646 tmpscr->door[1]=dUNLOCKED;
19647 setmapflag(si, mDOOR_DOWN);
19648
19649 if(di != 0xFFFF)
19650 setmapflag(di, mDOOR_UP);
19651 sfx(WAV_DOOR);
19652 markBmap(-1);
19653 }
19654 else return;
19655 }
19656 else if(tmpscr->door[1]==dBOSS)
19657 {
19658 if(game->lvlitems[dlevel]&liBOSSKEY)
19659 {
19660 putdoor(scrollbuf,0,down,dOPENBOSS);
19661 tmpscr->door[1]=dOPENBOSS;
19662 setmapflag(si, mDOOR_DOWN);
19663
19664 if(di != 0xFFFF)
19665 setmapflag(di, mDOOR_UP);
19666 sfx(WAV_DOOR);
19667 markBmap(-1);
19668 // Run Boss Key Script
19669 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19670 for ( int32_t q = 0; q < MAXITEMS; ++q )
19671 {
19672 if ( itemsbuf[q].family == itype_bosskey )
19673 {
19674 key_item = q; break;
19675 }
19676 }
19677 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19678 {
19679 ri = &(itemScriptData[key_item]);
19680 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19681 ri->Clear();
19682 item_doscript[key_item] = 1;
19683 itemscriptInitialised[key_item] = 0;
19684 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19685 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19686 }
19687 }
19688 else return;
19689 }
19690 break;
19691 }
19692 1 default: break;
19693 }
19694 1 }
19695 //left
19696
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
17 if ( y == 80 && x <= 32 )
19697 //!( (y!=80) && x>32 ) )
19698 {
19699 switch(dir)
19700 {
19701 case left:
19702 case l_up:
19703 case l_down:
19704 {
19705 di = nextscr(left);
19706 if(tmpscr->door[2]==dLOCKED)
19707 {
19708 if(usekey())
19709 {
19710 putdoor(scrollbuf,0,left,dUNLOCKED);
19711 tmpscr->door[2]=dUNLOCKED;
19712 setmapflag(si, mDOOR_LEFT);
19713
19714 if(di != 0xFFFF)
19715 setmapflag(di, mDOOR_RIGHT);
19716 sfx(WAV_DOOR);
19717 markBmap(-1);
19718 }
19719 else return;
19720 }
19721 else if(tmpscr->door[2]==dBOSS)
19722 {
19723 if(game->lvlitems[dlevel]&liBOSSKEY)
19724 {
19725 putdoor(scrollbuf,0,left,dOPENBOSS);
19726 tmpscr->door[2]=dOPENBOSS;
19727 setmapflag(si, mDOOR_LEFT);
19728
19729 if(di != 0xFFFF)
19730 setmapflag(di, mDOOR_RIGHT);
19731 sfx(WAV_DOOR);
19732 markBmap(-1);
19733 // Run Boss Key Script
19734 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19735 for ( int32_t q = 0; q < MAXITEMS; ++q )
19736 {
19737 if ( itemsbuf[q].family == itype_bosskey )
19738 {
19739 key_item = q; break;
19740 }
19741 }
19742 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19743 {
19744 ri = &(itemScriptData[key_item]);
19745 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19746 ri->Clear();
19747 item_doscript[key_item] = 1;
19748 itemscriptInitialised[key_item] = 0;
19749 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19750 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19751 }
19752 }
19753 else return;
19754 }
19755
19756 break;
19757
19758 }
19759 default: break;
19760 }
19761 }
19762 //right
19763
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 2 times.
17 if ( y == 80 && x >= 208 )
19764 //!((y!=80) && x<208 ) )
19765 {
19766
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 switch(dir)
19767 {
19768 case right:
19769 case r_down:
19770 case r_up:
19771 {
19772 2 di = nextscr(right);
19773
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(tmpscr->door[3]==dLOCKED)
19774 {
19775
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(usekey())
19776 {
19777 1 putdoor(scrollbuf,0,right,dUNLOCKED);
19778 1 tmpscr->door[3]=dUNLOCKED;
19779 1 setmapflag(si, mDOOR_RIGHT);
19780
19781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(di != 0xFFFF)
19782 1 setmapflag(di, mDOOR_LEFT);
19783 1 sfx(WAV_DOOR);
19784 1 markBmap(-1);
19785 1 }
19786 else return;
19787 1 }
19788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(tmpscr->door[3]==dBOSS)
19789 {
19790
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(game->lvlitems[dlevel]&liBOSSKEY)
19791 {
19792 1 putdoor(scrollbuf,0,right,dOPENBOSS);
19793 1 tmpscr->door[3]=dOPENBOSS;
19794 1 setmapflag(si, mDOOR_RIGHT);
19795
19796
19797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(di != 0xFFFF)
19798 1 setmapflag(di, mDOOR_LEFT);
19799 1 sfx(WAV_DOOR);
19800 1 markBmap(-1);
19801 // Run Boss Key Script
19802 1 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 for ( int32_t q = 0; q < MAXITEMS; ++q )
19804 {
19805
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 1 times.
68 if ( itemsbuf[q].family == itype_bosskey )
19806 {
19807 1 key_item = q; break;
19808 }
19809 67 }
19810
2/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //
19811 {
19812 ri = &(itemScriptData[key_item]);
19813 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19814 ri->Clear();
19815 item_doscript[key_item] = 1;
19816 itemscriptInitialised[key_item] = 0;
19817 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19818 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19819 }
19820
19821 1 }
19822 else return;
19823 1 }
19824
19825
19826 2 break;
19827 }
19828 default: break;
19829
19830 }
19831 2 }
19832 }
19833 79833 }
19834
19835 79833 void HeroClass::checkswordtap()
19836 {
19837
3/6
✓ Branch 0 taken 36363 times.
✓ Branch 1 taken 43470 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36363 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79833 if(attack!=wSword || charging<=0 || pushing<8) return;
19838
19839 int32_t bx=x;
19840 int32_t by=y+8;
19841
19842 switch(dir)
19843 {
19844 case up:
19845 if(!Up()) return;
19846
19847 by-=16;
19848 break;
19849
19850 case down:
19851 if(!Down()) return;
19852
19853 by+=16;
19854 bx+=8;
19855 break;
19856
19857 case left:
19858 if(!Left()) return;
19859
19860 bx-=16;
19861 by+=8;
19862 break;
19863
19864 case right:
19865 if(!Right()) return;
19866
19867 bx+=16;
19868 by+=8;
19869 break;
19870 }
19871
19872 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
19873
19874 attackclk=SWORDTAPFRAME;
19875 pushing=-8; //16 frames between taps
19876 tapping=true;
19877
19878 int32_t type = COMBOTYPE(bx,by);
19879
19880 if(!isCuttableType(type))
19881 {
19882 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
19883 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
19884
19885 // Layers
19886 for(int32_t i=0; i < 6; i++)
19887 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
19888 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
19889
19890 for(int32_t i=0; i<4; i++)
19891 if(tmpscr->door[i]==dBOMB && i==dir)
19892 switch(i)
19893 {
19894 case up:
19895 case down:
19896 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
19897
19898 break;
19899
19900 case left:
19901 case right:
19902 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
19903
19904 break;
19905 }
19906
19907 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
19908 }
19909
19910 79833 }
19911
19912 84 void HeroClass::fairycircle(int32_t type)
19913 {
19914
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1 times.
84 if(fairyclk==0)
19915 {
19916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 switch(type)
19917 {
19918 case REFILL_LIFE:
19919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(didstuff&did_fairy) return;
19920
19921 1 didstuff|=did_fairy;
19922 1 break;
19923
19924 case REFILL_MAGIC:
19925 if(didstuff&did_magic) return;
19926
19927 didstuff|=did_magic;
19928 break;
19929
19930 case REFILL_ALL:
19931 if(didstuff&did_all) return;
19932
19933 didstuff|=did_all;
19934 }
19935
19936 1 refill_what=type;
19937 1 refill_why=REFILL_FAIRY;
19938 1 StartRefill(type);
19939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
19940 1 else {action=freeze; FFCore.setHeroAction(freeze);}
19941 1 holdclk=0;
19942 1 hopclk=0;
19943 1 }
19944
19945 84 ++fairyclk;
19946
19947
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 81 times.
84 if(refilling!=REFILL_FAIRYDONE)
19948 {
19949
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(!refill())
19950 1 refilling=REFILL_FAIRYDONE;
19951 3 }
19952
19953
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 1 times.
81 else if(++holdclk>80)
19954 {
19955 1 reset_swordcharge();
19956 1 attackclk=0;
19957 1 action=none; FFCore.setHeroAction(none);
19958 1 fairyclk=0;
19959 1 holdclk=0;
19960 1 refill_why = 0;
19961 1 refilling=REFILL_NONE;
19962 1 map_bkgsfx(true);
19963 1 }
19964 84 }
19965
19966 8367 int32_t touchcombo(int32_t x,int32_t y)
19967 {
19968
2/2
✓ Branch 0 taken 16734 times.
✓ Branch 1 taken 8367 times.
25101 for (int32_t i = 0; i <= 1; ++i)
19969 {
19970
2/2
✓ Branch 0 taken 15850 times.
✓ Branch 1 taken 884 times.
16734 if(tmpscr2[i].valid!=0)
19971 {
19972
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 348 times.
884 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19973 {
19974
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
536 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19975 536 }
19976 else
19977 {
19978
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
348 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19979 }
19980 884 }
19981 16734 }
19982
1/2
✓ Branch 0 taken 8367 times.
✗ Branch 1 not taken.
8367 if (!_effectflag(x,y,1, -1)) return 0;
19983 8367 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
19984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8367 times.
8367 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19985 return 0;
19986
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 8367 times.
✗ Branch 2 not taken.
8367 switch(cmb.type)
19987 {
19988 case cBSGRAVE:
19989 case cGRAVE:
19990 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
19991 {
19992 break;
19993 }
19994
19995 [[fallthrough]];
19996 case cARMOS:
19997 {
19998 return cmb.type;
19999 }
20000 }
20001
20002 8367 return 0;
20003 8367 }
20004
20005 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
20006 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
20007
20008 static int32_t GridX(int32_t x)
20009 {
20010 return (x >> 4) << 4;
20011 }
20012
20013 //Snaps 'y' to the combo grid
20014 //Equivalent to calling ComboY(ComboAt(foo,y));
20015 static int32_t GridY(int32_t y)
20016 {
20017 return (y >> 4) << 4;
20018 }
20019
20020 int32_t grabComboFromPos(int32_t pos, int32_t type)
20021 {
20022 for(int32_t lyr = 6; lyr > -1; --lyr)
20023 {
20024 int32_t id = FFCore.tempScreens[lyr]->data[pos];
20025 if(combobuf[id].type == type)
20026 return id;
20027 }
20028 return -1;
20029 }
20030
20031 static int32_t typeMap[176];
20032 static int32_t istrig[176];
20033 static const int32_t SPTYPE_SOLID = -1;
20034 #define SP_VISITED 0x1
20035 #define SPFLAG(dir) (0x2<<dir)
20036 #define BEAM_AGE_LIMIT 32
20037 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
20038 {
20039 int32_t trigflag = set ? (1 << (set-1)) : ~0;
20040 if(spotdir > 3) return; //invalid dir
20041 bool doAge = true;
20042 byte f = 0;
20043 while(unsigned(curpos) < 176)
20044 {
20045 bool block_light = false;
20046 f = SPFLAG(spotdir);
20047 if((grid[curpos] & f) != f)
20048 {
20049 grid[curpos] |= f;
20050 istrig[curpos] |= trigflag;
20051 doAge = false;
20052 age = 0;
20053 }
20054 switch(spotdir)
20055 {
20056 case up:
20057 curpos -= 0x10;
20058 break;
20059 case down:
20060 curpos += 0x10;
20061 break;
20062 case left:
20063 if(!(curpos%0x10))
20064 curpos = -1;
20065 else --curpos;
20066 break;
20067 case right:
20068 ++curpos;
20069 if(!(curpos%0x10))
20070 curpos = -1;
20071 break;
20072 }
20073 if(unsigned(curpos) >= 176) break;
20074 switch(typeMap[curpos])
20075 {
20076 case SPTYPE_SOLID: case cBLOCKALL:
20077 curpos = -1;
20078 break;
20079 }
20080 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
20081 curpos = -1;
20082 if(unsigned(curpos) >= 176) break;
20083
20084 f = SPFLAG(oppositeDir[spotdir]);
20085 if((grid[curpos] & f) != f)
20086 {
20087 grid[curpos] |= f;
20088 istrig[curpos] |= trigflag;
20089 doAge = false;
20090 age = 0;
20091 }
20092 if(doAge)
20093 {
20094 if(++age > BEAM_AGE_LIMIT)
20095 break;
20096 }
20097 else doAge = true;
20098
20099 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
20100 spotdir = dir;
20101 else switch(typeMap[curpos])
20102 {
20103 case cLIGHTTARGET:
20104 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
20105 return;
20106 case cMIRROR:
20107 spotdir = oppositeDir[spotdir];
20108 break;
20109 case cMIRRORSLASH:
20110 switch(spotdir)
20111 {
20112 case up:
20113 spotdir = right; break;
20114 case right:
20115 spotdir = up; break;
20116 case down:
20117 spotdir = left; break;
20118 case left:
20119 spotdir = down; break;
20120 }
20121 break;
20122 case cMIRRORBACKSLASH:
20123 switch(spotdir)
20124 {
20125 case up:
20126 spotdir = left; break;
20127 case left:
20128 spotdir = up; break;
20129 case down:
20130 spotdir = right; break;
20131 case right:
20132 spotdir = down; break;
20133 }
20134 break;
20135 case cMAGICPRISM:
20136 for(byte d = 0; d < 4; ++d)
20137 {
20138 if(d == oppositeDir[spotdir]) continue;
20139 handleBeam(grid, age, d, curpos, set, block, refl);
20140 }
20141 return;
20142 case cMAGICPRISM4:
20143 for(byte d = 0; d < 4; ++d)
20144 {
20145 handleBeam(grid, age, d, curpos, set, block, refl);
20146 }
20147 return;
20148 }
20149 }
20150 }
20151
20152 79959 void HeroClass::handleSpotlights()
20153 {
20154 typedef byte spot_t;
20155 //Store each different tile/color as grids
20156 79959 std::map<int32_t, spot_t*> maps;
20157
1/2
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
79959 int32_t shieldid = getCurrentShield(false);
20158
2/2
✓ Branch 0 taken 1220 times.
✓ Branch 1 taken 78739 times.
79959 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
20159
3/4
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1220 times.
✓ Branch 3 taken 78739 times.
79959 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
20160
3/6
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79959 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 79959 times.
✗ Branch 5 not taken.
79959 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
20161 79959 memset(istrig, 0, sizeof(istrig));
20162
1/2
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
79959 clear_bitmap(lightbeam_bmp);
20163
20164
2/2
✓ Branch 0 taken 14072784 times.
✓ Branch 1 taken 79959 times.
14152743 for(size_t pos = 0; pos < 176; ++pos)
20165 {
20166 14072784 typeMap[pos] = 0;
20167
2/2
✓ Branch 0 taken 14072784 times.
✓ Branch 1 taken 98509488 times.
112582272 for(int32_t lyr = 6; lyr > -1; --lyr)
20168 {
20169 98509488 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
20170
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 98509488 times.
✗ Branch 2 not taken.
98509488 switch(cmb->type)
20171 {
20172 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
20173 case cMAGICPRISM: case cMAGICPRISM4:
20174 case cBLOCKALL: case cLIGHTTARGET:
20175 typeMap[pos] = cmb->type;
20176 break;
20177 case cGLASS:
20178 typeMap[pos] = 0;
20179 break;
20180 default:
20181 {
20182
4/4
✓ Branch 0 taken 42218352 times.
✓ Branch 1 taken 56291136 times.
✓ Branch 2 taken 34921071 times.
✓ Branch 3 taken 7297281 times.
98509488 if(lyr < 3 && (cmb->walk & 0xF))
20183 {
20184 7297281 typeMap[pos] = SPTYPE_SOLID;
20185 7297281 }
20186 98509488 continue; //next layer
20187 }
20188 }
20189 break; //hit a combo type
20190 }
20191 14072784 }
20192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79959 times.
79959 if(unsigned(heropos) < 176)
20193 {
20194
2/2
✓ Branch 0 taken 4751 times.
✓ Branch 1 taken 75208 times.
79959 switch(typeMap[heropos])
20195 {
20196 case SPTYPE_SOLID: case cBLOCKALL:
20197 4751 heropos = -1; //Blocked from hitting player
20198 4751 }
20199 79959 }
20200
20201
2/2
✓ Branch 0 taken 559713 times.
✓ Branch 1 taken 79959 times.
639672 for(size_t layer = 0; layer < 7; ++layer)
20202 {
20203 559713 mapscr* curlayer = FFCore.tempScreens[layer];
20204
2/2
✓ Branch 0 taken 98509488 times.
✓ Branch 1 taken 559713 times.
99069201 for(size_t pos = 0; pos < 176; ++pos)
20205 {
20206 //For each spotlight combo on each layer...
20207 98509488 newcombo const& cmb = combobuf[curlayer->data[pos]];
20208
1/2
✓ Branch 0 taken 98509488 times.
✗ Branch 1 not taken.
98509488 if(cmb.type == cSPOTLIGHT)
20209 {
20210 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
20211 int32_t id = (cmb.usrflags&cflag1)
20212 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
20213 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
20214 if(!id) continue;
20215 // zprint2("ID = %ld\n", id);
20216 //Get the grid array for this tile/color
20217 spot_t* grid;
20218 if(maps[id])
20219 grid = maps[id];
20220 else
20221 {
20222 grid = new spot_t[176];
20223 memset(grid, 0, sizeof(spot_t)*176);
20224 maps[id] = grid;
20225 }
20226 byte spotdir = cmb.attribytes[0];
20227 int32_t curpos = pos;
20228 if(spotdir > 3)
20229 {
20230 grid[curpos] |= SP_VISITED;
20231 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
20232 }
20233 if(refl && curpos == heropos)
20234 {
20235 spotdir = dir;
20236 }
20237 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
20238 }
20239 98509488 }
20240 559713 }
20241
20242 //Draw visuals
20243
2/4
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79959 times.
79959 for(auto it = maps.begin(); it != maps.end();)
20244 {
20245 int32_t id = it->first;
20246 spot_t* grid = it->second;
20247 //
20248 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
20249 int32_t tile = (id&0xFFFFFF);
20250 int32_t cs = (id>>24);
20251 byte c_inner = ((-id)&0x0000FF);
20252 byte c_middle = ((-id)&0x00FF00)>>8;
20253 byte c_outter = ((-id)&0xFF0000)>>16;
20254 //{ Setup color bitmap
20255 BITMAP* cbmp = NULL;
20256 if(id < 0)
20257 {
20258 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
20259 cbmp = create_bitmap_ex(8, 16*t_max, 16);
20260 clear_bitmap(cbmp);
20261 for(size_t q = 1; q < t_max; ++q)
20262 {
20263 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
20264 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
20265 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
20266 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
20267 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
20268 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
20269 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
20270 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
20271 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
20272 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
20273 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
20274 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
20275 }
20276 //t_gr
20277 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
20278 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
20279 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
20280 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
20281 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
20282 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
20283 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
20284 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
20285 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
20286 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
20287 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
20288 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
20289 //t_up
20290 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
20291 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
20292 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
20293 //t_down
20294 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
20295 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
20296 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
20297 //t_left
20298 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
20299 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
20300 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
20301 //t_right
20302 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
20303 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
20304 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
20305 //t_uleft
20306 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
20307 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
20308 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
20309 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
20310 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
20311 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
20312 //t_uright
20313 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
20314 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
20315 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
20316 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
20317 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
20318 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
20319 //t_dleft
20320 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
20321 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
20322 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
20323 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
20324 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
20325 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
20326 //t_dright
20327 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
20328 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
20329 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
20330 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
20331 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
20332 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
20333 //t_vert
20334 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
20335 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
20336 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
20337 //t_horz
20338 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
20339 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
20340 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
20341 //t_notup
20342 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
20343 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
20344 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
20345 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
20346 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
20347 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
20348 //t_notdown
20349 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
20350 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
20351 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
20352 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
20353 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
20354 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
20355 //t_notleft
20356 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
20357 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
20358 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
20359 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
20360 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
20361 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
20362 //t_notright
20363 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
20364 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
20365 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
20366 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
20367 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
20368 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
20369 //t_all
20370 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
20371 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
20372 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
20373 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
20374 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
20375 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
20376 }
20377 //}
20378 //
20379 for(size_t pos = 0; pos < 176; ++pos)
20380 {
20381 int32_t offs = -1;
20382 switch(grid[pos]>>1)
20383 {
20384 case 0: default:
20385 if(grid[pos])
20386 {
20387 offs = t_gr;
20388 break;
20389 }
20390 continue; //no draw this pos
20391 case 0b0001:
20392 offs = t_up;
20393 break;
20394 case 0b0010:
20395 offs = t_down;
20396 break;
20397 case 0b0100:
20398 offs = t_left;
20399 break;
20400 case 0b1000:
20401 offs = t_right;
20402 break;
20403 case 0b0011:
20404 offs = t_vert;
20405 break;
20406 case 0b1100:
20407 offs = t_horz;
20408 break;
20409 case 0b0101:
20410 offs = t_uleft;
20411 break;
20412 case 0b1001:
20413 offs = t_uright;
20414 break;
20415 case 0b0110:
20416 offs = t_dleft;
20417 break;
20418 case 0b1010:
20419 offs = t_dright;
20420 break;
20421 case 0b1110:
20422 offs = t_notup;
20423 break;
20424 case 0b1101:
20425 offs = t_notdown;
20426 break;
20427 case 0b1011:
20428 offs = t_notleft;
20429 break;
20430 case 0b0111:
20431 offs = t_notright;
20432 break;
20433 case 0b1111:
20434 offs = t_all;
20435 break;
20436 }
20437 if(id > 0) //tile
20438 {
20439 //Draw 'tile' at 'pos'
20440 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
20441 }
20442 else //colors
20443 {
20444 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
20445 }
20446 }
20447 //
20448 if(cbmp) destroy_bitmap(cbmp);
20449 delete[] it->second;
20450 it = maps.erase(it);
20451 }
20452 //Check triggers
20453 79959 bool hastrigs = false, istrigged = true;
20454
1/2
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
79959 bool alltrig = getmapflag(mLIGHTBEAM);
20455
2/2
✓ Branch 0 taken 79959 times.
✓ Branch 1 taken 559713 times.
639672 for(size_t layer = 0; layer < 7; ++layer)
20456 {
20457 559713 mapscr* curlayer = FFCore.tempScreens[layer];
20458
2/2
✓ Branch 0 taken 98509488 times.
✓ Branch 1 taken 559713 times.
99069201 for(size_t pos = 0; pos < 176; ++pos)
20459 {
20460 98509488 newcombo const* cmb = &combobuf[curlayer->data[pos]];
20461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98509488 times.
98509488 if(cmb->type == cLIGHTTARGET)
20462 {
20463 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20464 hastrigs = true;
20465 bool trigged = (istrig[pos]&trigflag);
20466 if(cmb->usrflags&cflag2) //Invert
20467 trigged = !trigged;
20468 if(cmb->usrflags&cflag1) //Solved Version
20469 {
20470 if(!(alltrig || trigged)) //Revert
20471 {
20472 curlayer->data[pos] -= 1;
20473 istrigged = false;
20474 }
20475 }
20476 else //Unsolved version
20477 {
20478 if(alltrig || trigged) //Light
20479 curlayer->data[pos] += 1;
20480 else istrigged = false;
20481 }
20482 }
20483
1/2
✓ Branch 0 taken 98509488 times.
✗ Branch 1 not taken.
98509488 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20484 {
20485 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20486 bool trigged = (istrig[pos]&trigflag);
20487 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20488 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20489 {
20490 do_trigger_combo(layer, pos);
20491 }
20492 }
20493 98509488 }
20494 559713 }
20495
1/2
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
79959 word c = tmpscr->numFFC();
20496
2/2
✓ Branch 0 taken 79959 times.
✓ Branch 1 taken 2350404 times.
2430363 for(word i=0; i<c; i++)
20497 {
20498 2350404 ffcdata& ffc = tmpscr->ffcs[i];
20499
1/2
✓ Branch 0 taken 2350404 times.
✗ Branch 1 not taken.
2350404 newcombo const* cmb = &combobuf[ffc.getData()];
20500
7/14
✓ Branch 0 taken 2350404 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2350404 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2350404 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2350404 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2350404 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2350404 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2350404 times.
✗ Branch 13 not taken.
2350404 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
20501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2350404 times.
2350404 if(cmb->type == cLIGHTTARGET)
20502 {
20503 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20504 hastrigs = true;
20505 bool trigged = (istrig[pos]&trigflag);
20506 if(cmb->usrflags&cflag2) //Invert
20507 trigged = !trigged;
20508 if(cmb->usrflags&cflag1) //Solved Version
20509 {
20510 if(!(alltrig || trigged)) //Revert
20511 {
20512 ffc.incData(-1);
20513 istrigged = false;
20514 }
20515 }
20516 else //Unsolved version
20517 {
20518 if(alltrig || trigged) //Light
20519 ffc.incData(1);
20520 else istrigged = false;
20521 }
20522 }
20523
1/2
✓ Branch 0 taken 2350404 times.
✗ Branch 1 not taken.
2350404 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20524 {
20525 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20526 bool trigged = (istrig[pos]&trigflag);
20527 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20528 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20529 {
20530 do_trigger_combo_ffc(i);
20531 }
20532 }
20533 2350404 }
20534
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 79959 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79959 if(hastrigs && istrigged && !alltrig)
20535 {
20536 hidden_entrance(0,true,false,-7);
20537 sfx(tmpscr->secretsfx);
20538 if(!(tmpscr->flags5&fTEMPSECRETS))
20539 {
20540 setmapflag(mSECRET);
20541 setmapflag(mLIGHTBEAM);
20542 }
20543 }
20544 79959 }
20545
20546 79833 void HeroClass::checktouchblk()
20547 {
20548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79833 times.
79833 if(toogam) return;
20549
20550
2/2
✓ Branch 0 taken 5436 times.
✓ Branch 1 taken 74397 times.
79833 if(!pushing)
20551 74397 return;
20552
20553 5436 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
20554
20555
2/4
✓ Branch 0 taken 5436 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5436 times.
5436 if(charging > 0 || spins > 0) //if not I probably will at some point...
20556 {
20557 if(Up()&&Left())tdir = (charging%2)*2;
20558 else if(Up()&&Right())tdir = (charging%2)*3;
20559 else if(Down()&&Left())tdir = 1+(charging%2)*1;
20560 else if(Down()&&Right())tdir = 1+(charging%2)*2;
20561 else
20562 {
20563 if(Up())tdir=0;
20564 else if(Down())tdir=1;
20565 else if(Left())tdir=2;
20566 else if(Right())tdir=3;
20567 }
20568 }
20569
20570 5436 int32_t tx=0,ty=-1;
20571
20572
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1415 times.
✓ Branch 2 taken 1516 times.
✓ Branch 3 taken 938 times.
✓ Branch 4 taken 1567 times.
5436 switch(tdir)
20573 {
20574 case up:
20575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1415 times.
1415 if(touchcombo(x,y+(bigHitbox?0:7)))
20576 {
20577 tx=x;
20578 ty=y+(bigHitbox?0:7);
20579 }
20580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1415 times.
1415 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
20581 {
20582 tx=x+8;
20583 ty=y+(bigHitbox?0:7);
20584 }
20585
20586 1415 break;
20587
20588 case down:
20589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1516 times.
1516 if(touchcombo(x,y+16))
20590 {
20591 tx=x;
20592 ty=y+16;
20593 }
20594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1516 times.
1516 else if(touchcombo(x+8,y+16))
20595 {
20596 tx=x+8;
20597 ty=y+16;
20598 }
20599
20600 1516 break;
20601
20602 case left:
20603
1/2
✓ Branch 0 taken 938 times.
✗ Branch 1 not taken.
938 if(touchcombo(x-1,y+15))
20604 {
20605 tx=x-1;
20606 ty=y+15;
20607 }
20608
20609 938 break;
20610
20611 case right:
20612
1/2
✓ Branch 0 taken 1567 times.
✗ Branch 1 not taken.
1567 if(touchcombo(x+16,y+15))
20613 {
20614 tx=x+16;
20615 ty=y+15;
20616 }
20617
20618 1567 break;
20619 }
20620
20621
1/2
✓ Branch 0 taken 5436 times.
✗ Branch 1 not taken.
5436 if(ty>=0)
20622 {
20623 ty&=0xF0;
20624 tx&=0xF0;
20625 int32_t di = ty+(tx>>4);
20626 if((getAction() != hopping || isSideViewHero()))
20627 {
20628 trigger_armos_grave(0, di, dir);
20629 }
20630 }
20631 79833 }
20632
20633 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
20634 {
20635 switch(cdir)
20636 {
20637 case up:
20638 cy-=16;
20639 break;
20640
20641 case down:
20642 cy+=16;
20643 break;
20644
20645 case left:
20646 cx-=16;
20647 break;
20648
20649 case right:
20650 cx+=16;
20651 break;
20652 }
20653
20654 // off the screen
20655 if(cx<0 || cy<0 || cx>255 || cy>175)
20656 {
20657 int32_t ns = nextscr(cdir);
20658
20659 if(ns==0xFFFF) return 0;
20660
20661 // want actual screen index, not game->maps[] index
20662 ns = (ns&127) + (ns>>7)*MAPSCRS;
20663
20664 switch(cdir)
20665 {
20666 case up:
20667 cy=160;
20668 break;
20669
20670 case down:
20671 cy=0;
20672 break;
20673
20674 case left:
20675 cx=240;
20676 break;
20677
20678 case right:
20679 cx=0;
20680 break;
20681 }
20682
20683 // from MAPCOMBO()
20684 int32_t cmb = (cy&0xF0)+(cx>>4);
20685
20686 if(cmb>175)
20687 return 0;
20688
20689 return TheMaps[ns].data[cmb]; // entire combo code
20690 }
20691
20692 return MAPCOMBO(cx,cy);
20693 }
20694
20695 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
20696 {
20697 switch(cdir)
20698 {
20699 case up:
20700 cy-=16;
20701 break;
20702
20703 case down:
20704 cy+=16;
20705 break;
20706
20707 case left:
20708 cx-=16;
20709 break;
20710
20711 case right:
20712 cx+=16;
20713 break;
20714 }
20715
20716 // off the screen
20717 if(cx<0 || cy<0 || cx>255 || cy>175)
20718 {
20719 int32_t ns = nextscr(cdir);
20720
20721 if(ns==0xFFFF) return 0;
20722
20723 // want actual screen index, not game->maps[] index
20724 ns = (ns&127) + (ns>>7)*MAPSCRS;
20725
20726 switch(cdir)
20727 {
20728 case up:
20729 cy=160;
20730 break;
20731
20732 case down:
20733 cy=0;
20734 break;
20735
20736 case left:
20737 cx=240;
20738 break;
20739
20740 case right:
20741 cx=0;
20742 break;
20743 }
20744
20745 // from MAPCOMBO()
20746 int32_t cmb = (cy&0xF0)+(cx>>4);
20747
20748 if(cmb>175)
20749 return 0;
20750
20751 if(!comboflag)
20752 {
20753 return TheMaps[ns].sflag[cmb]; // flag
20754 }
20755 else
20756 {
20757 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
20758 }
20759 }
20760
20761 if(comboflag)
20762 {
20763 return MAPCOMBOFLAG(cx,cy);
20764 }
20765
20766 return MAPFLAG(cx,cy);
20767 }
20768
20769 bool did_secret;
20770
20771 79833 void HeroClass::checkspecial()
20772 {
20773 79833 checktouchblk();
20774
20775 79833 bool hasmainguy = hasMainGuy(); // calculate it once
20776
20777
4/4
✓ Branch 0 taken 78857 times.
✓ Branch 1 taken 976 times.
✓ Branch 2 taken 46241 times.
✓ Branch 3 taken 32616 times.
79833 if(!(loaded_enemies && !hasmainguy))
20778 47217 did_secret=false;
20779 else
20780 {
20781 // after beating enemies
20782
20783 // item
20784
2/2
✓ Branch 0 taken 32598 times.
✓ Branch 1 taken 18 times.
32616 if(hasitem&(4|2|1))
20785 {
20786 18 int32_t Item=tmpscr->item;
20787
20788 //if(getmapflag())
20789 // Item=0;
20790
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20791 {
20792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(hasitem==1)
20793 18 sfx(WAV_CLEARED);
20794
20795
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
36 items.add(new item((zfix)tmpscr->itemx,
20796
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 18 times.
✗ Branch 11 not taken.
18 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20797
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
18 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20799 18 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20800 18 }
20801
20802 18 hasitem &= ~ (4|2|1);
20803 18 }
20804
20805 // generic 'Enemies->' trigger
20806
2/2
✓ Branch 0 taken 228312 times.
✓ Branch 1 taken 32616 times.
260928 for(auto lyr = 0; lyr < 7; ++lyr)
20807 {
20808
2/2
✓ Branch 0 taken 40182912 times.
✓ Branch 1 taken 228312 times.
40411224 for(auto pos = 0; pos < 176; ++pos)
20809 {
20810 40182912 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
20811
1/2
✓ Branch 0 taken 40182912 times.
✗ Branch 1 not taken.
40182912 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20812 {
20813 do_trigger_combo(lyr,pos);
20814 }
20815 40182912 }
20816 228312 }
20817 32616 word c = tmpscr->numFFC();
20818
2/2
✓ Branch 0 taken 1001538 times.
✓ Branch 1 taken 32616 times.
1034154 for(word i=0; i<c; i++)
20819 {
20820 1001538 ffcdata& ffc = tmpscr->ffcs[i];
20821 1001538 newcombo const& cmb = combobuf[ffc.getData()];
20822
1/2
✓ Branch 0 taken 1001538 times.
✗ Branch 1 not taken.
1001538 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20823 {
20824 do_trigger_combo_ffc(i);
20825 }
20826 1001538 }
20827
1/2
✓ Branch 0 taken 32616 times.
✗ Branch 1 not taken.
32616 if(tmpscr->flags9 & fENEMY_WAVES)
20828 {
20829 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
20830 }
20831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32616 times.
32616 if(!hasmainguy)
20832 {
20833 // if room has traps, guys don't come back
20834
2/2
✓ Branch 0 taken 16699392 times.
✓ Branch 1 taken 32616 times.
16732008 for(int32_t i=0; i<eMAXGUYS; i++)
20835 {
20836
4/4
✓ Branch 0 taken 486816 times.
✓ Branch 1 taken 16212576 times.
✓ Branch 2 taken 62808 times.
✓ Branch 3 taken 424008 times.
16699392 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
20837
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62808 if(guys.idCount(i) && !getmapflag(mTMPNORET))
20838 setmapflag(mTMPNORET);
20839 16699392 }
20840 // clear enemies and open secret
20841
4/4
✓ Branch 0 taken 30988 times.
✓ Branch 1 taken 1628 times.
✓ Branch 2 taken 30979 times.
✓ Branch 3 taken 9 times.
32616 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
20842 {
20843 9 bool only16_31 = get_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
20844 9 hidden_entrance(0,true,only16_31,-2);
20845
20846
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
20847 {
20848 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
20849 }
20850
20851 9 sfx(tmpscr->secretsfx);
20852 9 did_secret=true;
20853 9 }
20854 32616 }
20855 }
20856
20857 // doors
20858
2/2
✓ Branch 0 taken 69720 times.
✓ Branch 1 taken 299878 times.
369598 for(int32_t i=0; i<4; i++)
20859
2/2
✓ Branch 0 taken 289765 times.
✓ Branch 1 taken 10113 times.
299878 if(tmpscr->door[i]==dSHUTTER)
20860 {
20861
4/4
✓ Branch 0 taken 9831 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 9821 times.
10113 if(opendoors==0 && loaded_enemies)
20862 {
20863
4/4
✓ Branch 0 taken 5601 times.
✓ Branch 1 taken 4220 times.
✓ Branch 2 taken 5584 times.
✓ Branch 3 taken 17 times.
9821 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
20864 17 opendoors=12;
20865 9821 }
20866
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 62 times.
292 else if(opendoors<0)
20867 62 ++opendoors;
20868
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 19 times.
230 else if((--opendoors)==0)
20869 19 openshutters();
20870
20871 10113 break;
20872 }
20873
20874 // set boss flag when boss is gone
20875
6/6
✓ Branch 0 taken 78857 times.
✓ Branch 1 taken 976 times.
✓ Branch 2 taken 1636 times.
✓ Branch 3 taken 77221 times.
✓ Branch 4 taken 1101 times.
✓ Branch 5 taken 535 times.
79833 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
20876 {
20877 535 game->lvlitems[dlevel]|=liBOSS;
20878 535 stop_sfx(tmpscr->bosssfx);
20879 535 }
20880
20881
1/2
✓ Branch 0 taken 79833 times.
✗ Branch 1 not taken.
79833 if(getmapflag(mCHEST)) // if special stuff done before
20882 {
20883 remove_chests((currscr>=128)?1:0);
20884 }
20885
20886
1/2
✓ Branch 0 taken 79833 times.
✗ Branch 1 not taken.
79833 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
20887 {
20888 remove_lockedchests((currscr>=128)?1:0);
20889 }
20890
20891
1/2
✓ Branch 0 taken 79833 times.
✗ Branch 1 not taken.
79833 if(getmapflag(mBOSSCHEST)) // if special stuff done before
20892 {
20893 remove_bosschests((currscr>=128)?1:0);
20894 }
20895
20896 79833 clear_xstatecombos((currscr>=128)?1:0);
20897
20898
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79833 if((hasitem&8) && triggered_screen_secrets)
20899 {
20900 int32_t Item=tmpscr->item;
20901
20902 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20903 {
20904 items.add(new item((zfix)tmpscr->itemx,
20905 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20906 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20907 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20908 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20909 }
20910
20911 hasitem &= ~8;
20912 }
20913 79833 }
20914
20915 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
20916 58018 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
20917 {
20918 int32_t tmp;
20919 58018 poses[0] = COMBOPOS(x1,y1);
20920
20921 58018 tmp = COMBOPOS(x1,y2);
20922
2/2
✓ Branch 0 taken 43107 times.
✓ Branch 1 taken 14911 times.
58018 if(tmp == poses[0])
20923 43107 poses[1] = -1;
20924 14911 else poses[1] = tmp;
20925
20926 58018 tmp = COMBOPOS(x2,y1);
20927
3/4
✓ Branch 0 taken 29849 times.
✓ Branch 1 taken 28169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29849 times.
58018 if(tmp == poses[0] || tmp == poses[1])
20928 28169 poses[2] = -1;
20929 29849 else poses[2] = tmp;
20930
20931 58018 tmp = COMBOPOS(x2,y2);
20932
6/6
✓ Branch 0 taken 36370 times.
✓ Branch 1 taken 21648 times.
✓ Branch 2 taken 29849 times.
✓ Branch 3 taken 6521 times.
✓ Branch 4 taken 21459 times.
✓ Branch 5 taken 8390 times.
58018 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
20933 49628 poses[3] = -1;
20934 8390 else poses[3] = tmp;
20935 58018 }
20936
20937 79833 void HeroClass::checkspecial2(int32_t *ls)
20938 {
20939
4/6
✓ Branch 0 taken 65186 times.
✓ Branch 1 taken 14647 times.
✓ Branch 2 taken 65186 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 65186 times.
79833 if(get_bit(quest_rules,qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
20940 {
20941
2/2
✓ Branch 0 taken 16948 times.
✓ Branch 1 taken 48238 times.
65186 if(y.getInt()&7)
20942 16948 return;
20943
20944
2/2
✓ Branch 0 taken 28850 times.
✓ Branch 1 taken 19388 times.
48238 if(x.getInt()&7)
20945 28850 return;
20946 19388 }
20947
20948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34035 times.
34035 if(toogam) return;
20949
20950 34035 bool didstrig = false;
20951
20952
2/2
✓ Branch 0 taken 68070 times.
✓ Branch 1 taken 34035 times.
102105 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
20953 {
20954
4/4
✓ Branch 0 taken 136140 times.
✓ Branch 1 taken 68070 times.
✓ Branch 2 taken 272280 times.
✓ Branch 3 taken 136140 times.
476490 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
20955 {
20956
2/2
✓ Branch 0 taken 136140 times.
✓ Branch 1 taken 136140 times.
272280 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
20957 272280 int32_t stype = cmb.type;
20958 272280 int32_t warpsound = cmb.attribytes[0];
20959
1/2
✓ Branch 0 taken 272280 times.
✗ Branch 1 not taken.
272280 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
20960 stype = cNONE;
20961
1/2
✓ Branch 0 taken 272280 times.
✗ Branch 1 not taken.
272280 if(stype==cSWARPA)
20962 {
20963 if(tmpscr->flags5&fDIRECTSWARP)
20964 {
20965 didpit=true;
20966 pitx=x;
20967 pity=y;
20968 }
20969
20970 sdir=dir;
20971 dowarp(0,0,warpsound);
20972 return;
20973 }
20974
20975
1/2
✓ Branch 0 taken 272280 times.
✗ Branch 1 not taken.
272280 if(stype==cSWARPB)
20976 {
20977 if(tmpscr->flags5&fDIRECTSWARP)
20978 {
20979 didpit=true;
20980 pitx=x;
20981 pity=y;
20982 }
20983
20984 sdir=dir;
20985 dowarp(0,1,warpsound);
20986 return;
20987 }
20988
20989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272280 times.
272280 if(stype==cSWARPC)
20990 {
20991 if(tmpscr->flags5&fDIRECTSWARP)
20992 {
20993 didpit=true;
20994 pitx=x;
20995 pity=y;
20996 }
20997
20998 sdir=dir;
20999 dowarp(0,2,warpsound);
21000 return;
21001 }
21002
21003
1/2
✓ Branch 0 taken 272280 times.
✗ Branch 1 not taken.
272280 if(stype==cSWARPD)
21004 {
21005 if(tmpscr->flags5&fDIRECTSWARP)
21006 {
21007 didpit=true;
21008 pitx=x;
21009 pity=y;
21010 }
21011
21012 sdir=dir;
21013 dowarp(0,3,warpsound);
21014 return;
21015 }
21016
21017
1/2
✓ Branch 0 taken 272280 times.
✗ Branch 1 not taken.
272280 if(stype==cSWARPR)
21018 {
21019 if(tmpscr->flags5&fDIRECTSWARP)
21020 {
21021 didpit=true;
21022 pitx=x;
21023 pity=y;
21024 }
21025
21026 sdir=dir;
21027 dowarp(0,(zc_oldrand()%4),warpsound);
21028 return;
21029 }
21030
21031
5/6
✓ Branch 0 taken 272251 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 272251 times.
✓ Branch 4 taken 272251 times.
✓ Branch 5 taken 29 times.
272280 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=MAPCOMBO(x+j,y+i))
21032 {
21033 // zprint("Step Secs\n");
21034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29 if(stype==cSTRIGFLAG && canPermSecret())
21035 {
21036 if(!didstrig)
21037 {
21038 stepsecret = ((int32_t)(y+i)&0xF0)+((int32_t)(x+j)>>4);
21039
21040 if(!(tmpscr->flags5&fTEMPSECRETS))
21041 {
21042 setmapflag(mSECRET);
21043 }
21044 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
21045 //zprint("Step Secrets SFX: %d\n", thesfx);
21046 sfx(warpsound,pan((int32_t)x));
21047 hidden_entrance(0,true,false);
21048 didstrig = true;
21049 }
21050 }
21051 else
21052 {
21053
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 12 times.
29 if(!didstrig)
21054 {
21055 12 stepsecret = ((int32_t)(y+i)&0xF0)+((int32_t)(x+j)>>4);
21056 12 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21057 12 hidden_entrance(0,true,only16_31);
21058 12 didstrig = true;
21059 //play trigger sound
21060 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
21061 //zprint("Step Secrets SFX: %d\n", thesfx);
21062 //sfx(thesfx,pan((int32_t)x));
21063 12 sfx(warpsound,pan((int32_t)x));
21064 12 }
21065 }
21066 29 }
21067 408420 }
21068 68070 }
21069
21070 34035 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
21071
21072 // check if he's standing on a warp he just came out of
21073 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
21074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34035 times.
34035 if (!get_bit(quest_rules,qr_210_WARPRETURN))
21075 {
21076
6/6
✓ Branch 0 taken 34000 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 5409 times.
✓ Branch 3 taken 28591 times.
✓ Branch 4 taken 419 times.
✓ Branch 5 taken 4990 times.
34035 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
21077 {
21078
5/6
✓ Branch 0 taken 4968 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 4942 times.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4942 times.
4990 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
21079 {
21080
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4937 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
4942 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21081 4942 else return;
21082 }
21083 48 }
21084 29093 }
21085 else
21086 {
21087 if((int(y)&0xF8)==warpy)
21088 {
21089 if(x==warpx)
21090 {
21091 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21092 else return;
21093 }
21094 }
21095 }
21096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29093 times.
29093 if (!RaftPass) warpy=-1;
21097
21098
6/6
✓ Branch 0 taken 29036 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 1196 times.
✓ Branch 3 taken 27840 times.
✓ Branch 4 taken 777 times.
✓ Branch 5 taken 419 times.
29093 if(((int32_t)y<raftwarpy-(get_bit(quest_rules, qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_bit(quest_rules, qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
21099 {
21100 28316 raftwarpy = -1;
21101 28316 }
21102
6/6
✓ Branch 0 taken 29050 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 810 times.
✓ Branch 3 taken 28240 times.
✓ Branch 4 taken 638 times.
✓ Branch 5 taken 172 times.
29093 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
21103 {
21104 28455 raftwarpx = -1;
21105 28455 }
21106 29093 int32_t tx=x;
21107 29093 int32_t ty=y;
21108
21109 29093 int32_t flag=0;
21110 29093 int32_t flag2=0;
21111 29093 int32_t flag3=0;
21112 29093 int32_t type=0;
21113 29093 int32_t water=0;
21114 29093 int32_t index = 0;
21115
21116 29093 bool setsave=false;
21117 29093 int32_t warpsfx2 = 0;
21118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29093 times.
29093 if (RaftPass) goto RaftingStuff;
21119
21120 //bool gotpit=false;
21121
21122 int32_t x1,x2,y1,y2;
21123 29093 x1 = tx;
21124 29093 x2 = tx+15;
21125 29093 y1 = ty;
21126 29093 y2 = ty+15;
21127
21128
3/4
✓ Branch 0 taken 15263 times.
✓ Branch 1 taken 13830 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15263 times.
29093 if((diagonalMovement||NO_GRIDLOCK))
21129 {
21130 13830 x1 = tx+4;
21131 13830 x2 = tx+11;
21132 13830 y1 = ty+4;
21133 13830 y2 = ty+11;
21134 13830 }
21135
21136 int32_t types[4];
21137 29093 types[0]=types[1]=types[2]=types[3]=-1;
21138 int32_t cids[4];
21139 int32_t ffcids[4];
21140 29093 cids[0]=cids[1]=cids[2]=cids[3]=-1;
21141 29093 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
21142 //
21143 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
21144 //
21145 29093 types[0] = MAPFLAG(x1,y1);
21146 29093 types[1] = MAPFLAG(x1,y2);
21147 29093 types[2] = MAPFLAG(x2,y1);
21148 29093 types[3] = MAPFLAG(x2,y2);
21149
21150
21151 //MAPFFCOMBO
21152
21153
21154
6/6
✓ Branch 0 taken 28967 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 28934 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 92 times.
✓ Branch 5 taken 28842 times.
29093 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21155 28842 flag = types[0];
21156
21157 // 2.10 compatibility...
21158
7/10
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 74 times.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 54 times.
251 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
21159 flag = types[0];
21160
21161
21162 29093 types[0] = MAPCOMBOFLAG(x1,y1);
21163 29093 types[1] = MAPCOMBOFLAG(x1,y2);
21164 29093 types[2] = MAPCOMBOFLAG(x2,y1);
21165 29093 types[3] = MAPCOMBOFLAG(x2,y2);
21166
21167
6/6
✓ Branch 0 taken 28997 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 28994 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 28940 times.
29093 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21168 28940 flag2 = types[0];
21169
21170 29093 types[0] = MAPFFCOMBOFLAG(x1,y1);
21171 29093 types[1] = MAPFFCOMBOFLAG(x1,y2);
21172 29093 types[2] = MAPFFCOMBOFLAG(x2,y1);
21173 29093 types[3] = MAPFFCOMBOFLAG(x2,y2);
21174
21175
21176 //
21177
21178
6/6
✓ Branch 0 taken 29089 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 29079 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 29078 times.
29093 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21179 29078 flag3 = types[0];
21180
21181 //
21182 // Now, let's check for warp combos...
21183 //
21184
21185 //
21186
21187 29093 cids[0] = MAPCOMBO(x1,y1);
21188 29093 cids[1] = MAPCOMBO(x1,y2);
21189 29093 cids[2] = MAPCOMBO(x2,y1);
21190 29093 cids[3] = MAPCOMBO(x2,y2);
21191
21192 29093 types[0] = COMBOTYPE(x1,y1);
21193
21194
2/2
✓ Branch 0 taken 28129 times.
✓ Branch 1 taken 964 times.
29093 if(MAPFFCOMBO(x1,y1))
21195 {
21196 964 types[0] = FFCOMBOTYPE(x1,y1);
21197 964 cids[0] = MAPFFCOMBO(x1,y1);
21198 964 }
21199
21200 29093 types[1] = COMBOTYPE(x1,y2);
21201
21202
2/2
✓ Branch 0 taken 28458 times.
✓ Branch 1 taken 635 times.
29093 if(MAPFFCOMBO(x1,y2))
21203 {
21204 635 types[1] = FFCOMBOTYPE(x1,y2);
21205 635 cids[1] = MAPFFCOMBO(x1,y2);
21206 635 }
21207
21208 29093 types[2] = COMBOTYPE(x2,y1);
21209
21210
2/2
✓ Branch 0 taken 28253 times.
✓ Branch 1 taken 840 times.
29093 if(MAPFFCOMBO(x2,y1))
21211 {
21212 840 types[2] = FFCOMBOTYPE(x2,y1);
21213 840 cids[2] = MAPFFCOMBO(x2,y1);
21214 840 }
21215 29093 types[3] = COMBOTYPE(x2,y2);
21216
21217
2/2
✓ Branch 0 taken 28617 times.
✓ Branch 1 taken 476 times.
29093 if(MAPFFCOMBO(x2,y2))
21218 {
21219 476 types[3] = FFCOMBOTYPE(x2,y2);
21220 476 cids[3] = MAPFFCOMBO(x2,y2);
21221 476 }
21222 // Change B, C and D warps into A, for the comparison below...
21223
2/2
✓ Branch 0 taken 116372 times.
✓ Branch 1 taken 29093 times.
145465 for(int32_t i=0; i<4; i++)
21224 {
21225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21226 {
21227 types[i] = cNONE;
21228 continue;
21229 }
21230
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 116228 times.
116372 if(types[i]==cCAVE)
21231 {
21232 144 index=0;
21233 144 warpsfx2 = combobuf[cids[i]].attribytes[0];
21234 144 }
21235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116228 times.
116228 else if(types[i]==cCAVEB)
21236 {
21237 types[i]=cCAVE;
21238 index=1;
21239 warpsfx2 = combobuf[cids[i]].attribytes[0];
21240 }
21241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116228 times.
116228 else if(types[i]==cCAVEC)
21242 {
21243 types[i]=cCAVE;
21244 index=2;
21245 warpsfx2 = combobuf[cids[i]].attribytes[0];
21246 }
21247
1/2
✓ Branch 0 taken 116228 times.
✗ Branch 1 not taken.
116228 else if(types[i]==cCAVED)
21248 {
21249 types[i]=cCAVE;
21250 index=3;
21251 warpsfx2 = combobuf[cids[i]].attribytes[0];
21252 }
21253
21254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 if(types[i]==cPIT)
21255 {
21256 index=0;
21257 warpsfx2 = combobuf[cids[i]].attribytes[0];
21258 }
21259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cPITB)
21260 {
21261 types[i]=cPIT;
21262 warpsfx2 = combobuf[cids[i]].attribytes[0];
21263 index=1;
21264 }
21265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cPITC)
21266 {
21267 types[i]=cPIT;
21268 warpsfx2 = combobuf[cids[i]].attribytes[0];
21269 index=2;
21270 }
21271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cPITD)
21272 {
21273 types[i]=cPIT;
21274 warpsfx2 = combobuf[cids[i]].attribytes[0];
21275 index=3;
21276 }
21277
1/2
✓ Branch 0 taken 116372 times.
✗ Branch 1 not taken.
116372 else if(types[i]==cPITR)
21278 {
21279 types[i]=cPIT;
21280 warpsfx2 = combobuf[cids[i]].attribytes[0];
21281 index=zc_oldrand()%4;
21282 }
21283
21284
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 116354 times.
116372 if(types[i]==cSTAIR)
21285 {
21286 18 index=0;
21287 18 warpsfx2 = combobuf[cids[i]].attribytes[0];
21288 18 }
21289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116354 times.
116354 else if(types[i]==cSTAIRB)
21290 {
21291 types[i]=cSTAIR;
21292 warpsfx2 = combobuf[cids[i]].attribytes[0];
21293 index=1;
21294 }
21295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116354 times.
116354 else if(types[i]==cSTAIRC)
21296 {
21297 types[i]=cSTAIR;
21298 warpsfx2 = combobuf[cids[i]].attribytes[0];
21299 index=2;
21300 }
21301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116354 times.
116354 else if(types[i]==cSTAIRD)
21302 {
21303 types[i]=cSTAIR;
21304 warpsfx2 = combobuf[cids[i]].attribytes[0];
21305 index=3;
21306 }
21307
1/2
✓ Branch 0 taken 116354 times.
✗ Branch 1 not taken.
116354 else if(types[i]==cSTAIRR)
21308 {
21309 types[i]=cSTAIR;
21310 index=zc_oldrand()%4;
21311 warpsfx2 = combobuf[cids[i]].attribytes[0];
21312 }
21313
21314
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 116364 times.
116372 if(types[i]==cCAVE2)
21315 {
21316 8 index=0;
21317 8 warpsfx2 = combobuf[cids[i]].attribytes[0];
21318 8 }
21319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116364 times.
116364 else if(types[i]==cCAVE2B)
21320 {
21321 types[i]=cCAVE2;
21322 index=1;
21323 warpsfx2 = combobuf[cids[i]].attribytes[0];
21324 }
21325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116364 times.
116364 else if(types[i]==cCAVE2C)
21326 {
21327 types[i]=cCAVE2;
21328 warpsfx2 = combobuf[cids[i]].attribytes[0];
21329 index=2;
21330 }
21331
1/2
✓ Branch 0 taken 116364 times.
✗ Branch 1 not taken.
116364 else if(types[i]==cCAVE2D)
21332 {
21333 types[i]=cCAVE2;
21334 warpsfx2 = combobuf[cids[i]].attribytes[0];
21335 index=3;
21336 }
21337
21338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 if(types[i]==cSWIMWARP)
21339 {
21340 index=0;
21341 warpsfx2 = combobuf[cids[i]].attribytes[0];
21342 }
21343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cSWIMWARPB)
21344 {
21345 types[i]=cSWIMWARP;
21346 warpsfx2 = combobuf[cids[i]].attribytes[0];
21347 index=1;
21348 }
21349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cSWIMWARPC)
21350 {
21351 types[i]=cSWIMWARP;
21352 warpsfx2 = combobuf[cids[i]].attribytes[0];
21353 index=2;
21354 }
21355
1/2
✓ Branch 0 taken 116372 times.
✗ Branch 1 not taken.
116372 else if(types[i]==cSWIMWARPD)
21356 {
21357 types[i]=cSWIMWARP;
21358 warpsfx2 = combobuf[cids[i]].attribytes[0];
21359 index=3;
21360 }
21361
21362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 if(types[i]==cDIVEWARP)
21363 {
21364 index=0;
21365 warpsfx2 = combobuf[cids[i]].attribytes[0];
21366 }
21367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cDIVEWARPB)
21368 {
21369 types[i]=cDIVEWARP;
21370 warpsfx2 = combobuf[cids[i]].attribytes[0];
21371 index=1;
21372 }
21373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cDIVEWARPC)
21374 {
21375 types[i]=cDIVEWARP;
21376 warpsfx2 = combobuf[cids[i]].attribytes[0];
21377 index=2;
21378 }
21379
1/2
✓ Branch 0 taken 116372 times.
✗ Branch 1 not taken.
116372 else if(types[i]==cDIVEWARPD)
21380 {
21381 types[i]=cDIVEWARP;
21382 warpsfx2 = combobuf[cids[i]].attribytes[0];
21383 index=3;
21384 }
21385
21386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
21387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
21388
1/2
✓ Branch 0 taken 116372 times.
✗ Branch 1 not taken.
116372 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
21389 116372 }
21390
21391 // Special case for step combos; otherwise, they act oddly in some cases
21392
7/8
✓ Branch 0 taken 26953 times.
✓ Branch 1 taken 2140 times.
✓ Branch 2 taken 26221 times.
✓ Branch 3 taken 732 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2872 times.
✓ Branch 6 taken 854 times.
✓ Branch 7 taken 854 times.
29093 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
21393 {
21394
6/8
✓ Branch 0 taken 25284 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 25284 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 25283 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
27075 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21395 25283 type = types[1];
21396 25367 }
21397
21398 //Generic Step
21399
6/8
✓ Branch 0 taken 29010 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 29010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 29009 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
29093 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21400 {
21401 int32_t poses[4];
21402 int32_t sensPoses[4];
21403 29009 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
21404 29009 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
21405
3/4
✓ Branch 0 taken 15180 times.
✓ Branch 1 taken 13829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15180 times.
29009 if(diagonalMovement||NO_GRIDLOCK)
21406 13829 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
21407 15180 else getPoses(poses, tx, ty, tx+15, ty+15);
21408 29009 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
21409 29009 bool hasStep[4] = {false};
21410
2/2
✓ Branch 0 taken 116036 times.
✓ Branch 1 taken 29009 times.
145045 for(auto p = 0; p < 4; ++p)
21411 {
21412
2/2
✓ Branch 0 taken 116036 times.
✓ Branch 1 taken 812252 times.
928288 for(auto lyr = 0; lyr < 7; ++lyr)
21413 {
21414
2/2
✓ Branch 0 taken 392476 times.
✓ Branch 1 taken 419776 times.
812252 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21415
3/4
✓ Branch 0 taken 392476 times.
✓ Branch 1 taken 419776 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 812252 times.
812252 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
21416 812252 || types[p] == cSTEP)
21417 {
21418 hasStep[p] = true;
21419 break;
21420 }
21421 812252 }
21422 116036 }
21423 29009 bool canNormalStep = true;
21424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29009 times.
29009 for(auto p = 0; p < 4; ++p)
21425 {
21426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29009 times.
29009 if(poses[p] < 0) continue;
21427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29009 times.
29009 if(!hasStep[p])
21428 {
21429 29009 canNormalStep = false;
21430 29009 break;
21431 }
21432 }
21433
2/2
✓ Branch 0 taken 116036 times.
✓ Branch 1 taken 29009 times.
145045 for(auto p = 0; p < 4; ++p)
21434 {
21435
2/2
✓ Branch 0 taken 812252 times.
✓ Branch 1 taken 116036 times.
928288 for(auto lyr = 0; lyr < 7; ++lyr)
21436 {
21437
2/2
✓ Branch 0 taken 392476 times.
✓ Branch 1 taken 419776 times.
812252 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21438
2/2
✓ Branch 0 taken 385700 times.
✓ Branch 1 taken 426552 times.
812252 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
21439
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 812252 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
812252 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
21440 {
21441 do_trigger_combo(lyr,poses[p]);
21442 if(poses[p] == sensPoses[p]) continue;
21443 }
21444
3/4
✓ Branch 0 taken 385700 times.
✓ Branch 1 taken 426552 times.
✓ Branch 2 taken 385700 times.
✗ Branch 3 not taken.
812252 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
21445 {
21446 do_trigger_combo(lyr,sensPoses[p]);
21447 }
21448 812252 }
21449 116036 }
21450 29009 word c = tmpscr->numFFC();
21451
2/2
✓ Branch 0 taken 724067 times.
✓ Branch 1 taken 29009 times.
753076 for(word i=0; i<c; i++)
21452 {
21453 724067 bool found = false;
21454
2/2
✓ Branch 0 taken 1448134 times.
✓ Branch 1 taken 724067 times.
2172201 for(auto xch = 0; xch < 2; ++xch)
21455 {
21456
2/2
✓ Branch 0 taken 2896268 times.
✓ Branch 1 taken 1448134 times.
4344402 for(auto ych = 0; ych < 2; ++ych)
21457 {
21458
2/2
✓ Branch 0 taken 2892839 times.
✓ Branch 1 taken 3429 times.
2896268 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
21459 {
21460 3429 found = true;
21461 3429 }
21462 2896268 }
21463 1448134 }
21464
2/2
✓ Branch 0 taken 722217 times.
✓ Branch 1 taken 1850 times.
724067 if (found)
21465 {
21466 1850 ffcdata& ffc = tmpscr->ffcs[i];
21467 1850 newcombo const* cmb = &combobuf[ffc.getData()];
21468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1850 times.
1850 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
21469 {
21470 do_trigger_combo_ffc(i);
21471 }
21472 1850 }
21473 724067 }
21474 29009 }
21475
21476 //
21477 // Now, let's check for Save combos...
21478 //
21479 29093 x1 = tx+4;
21480 29093 x2 = tx+11;
21481 29093 y1 = ty+4;
21482 29093 y2 = ty+11;
21483
21484 29093 types[0] = COMBOTYPE(x1,y1);
21485 29093 cids[0] = MAPCOMBO(x1,y1);
21486
21487
2/2
✓ Branch 0 taken 28129 times.
✓ Branch 1 taken 964 times.
29093 if(MAPFFCOMBO(x1,y1))
21488 {
21489 964 types[0] = FFCOMBOTYPE(x1,y1);
21490 964 cids[0] = MAPFFCOMBO(x1,y1);
21491 964 }
21492
21493 29093 types[1] = COMBOTYPE(x1,y2);
21494 29093 cids[1] = MAPCOMBO(x1,y2);
21495
21496
2/2
✓ Branch 0 taken 28458 times.
✓ Branch 1 taken 635 times.
29093 if(MAPFFCOMBO(x1,y2))
21497 {
21498 635 types[1] = FFCOMBOTYPE(x1,y2);
21499 635 cids[1] = MAPFFCOMBO(x1,y2);
21500 635 }
21501
21502 29093 types[2] = COMBOTYPE(x2,y1);
21503 29093 cids[2] = MAPCOMBO(x2,y1);
21504
21505
2/2
✓ Branch 0 taken 28253 times.
✓ Branch 1 taken 840 times.
29093 if(MAPFFCOMBO(x2,y1))
21506 {
21507 840 types[2] = FFCOMBOTYPE(x2,y1);
21508 840 cids[2] = MAPFFCOMBO(x2,y1);
21509 840 }
21510
21511 29093 types[3] = COMBOTYPE(x2,y2);
21512 29093 cids[3] = MAPCOMBO(x2,y2);
21513
21514
2/2
✓ Branch 0 taken 28617 times.
✓ Branch 1 taken 476 times.
29093 if(MAPFFCOMBO(x2,y2))
21515 {
21516 476 types[3] = FFCOMBOTYPE(x2,y2);
21517 476 cids[3] = MAPFFCOMBO(x2,y2);
21518 476 }
21519
21520
21521
2/2
✓ Branch 0 taken 29093 times.
✓ Branch 1 taken 116372 times.
145465 for(int32_t i=0; i<4; i++)
21522 {
21523
1/2
✓ Branch 0 taken 116372 times.
✗ Branch 1 not taken.
116372 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21524 {
21525 if(types[i] == cSAVE || types[i] == cSAVE2)
21526 {
21527 types[i] = cNONE;
21528 setsave = false;
21529 break;
21530 }
21531 }
21532
1/2
✓ Branch 0 taken 116372 times.
✗ Branch 1 not taken.
116372 if(types[i]==cSAVE) setsave=true;
21533
21534
1/2
✓ Branch 0 taken 116372 times.
✗ Branch 1 not taken.
116372 if(types[i]==cSAVE2) setsave=true;
21535 116372 }
21536
21537
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 29093 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
29093 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21538 {
21539 last_savepoint_id = cids[0];
21540 type = types[0];
21541 }
21542 //
21543 // Now, let's check for Drowning combos...
21544 //
21545
3/4
✓ Branch 0 taken 15263 times.
✓ Branch 1 taken 13830 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15263 times.
29093 if(get_bit(quest_rules,qr_DROWN) || CanSideSwim())
21546 {
21547 13830 y1 = ty+9;
21548 13830 y2 = ty+15;
21549
1/2
✓ Branch 0 taken 13830 times.
✗ Branch 1 not taken.
13830 if (get_bit(quest_rules, qr_SMARTER_WATER))
21550 {
21551
3/4
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 13542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 280 times.
14110 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
21552
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 8 times.
288 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
21553
1/2
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
280 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
21554 280 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
21555 13830 }
21556 else
21557 {
21558 types[0] = COMBOTYPE(x1,y1);
21559
21560 if(MAPFFCOMBO(x1,y1))
21561 types[0] = FFCOMBOTYPE(x1,y1);
21562
21563 types[1] = COMBOTYPE(x1,y2);
21564
21565 if(MAPFFCOMBO(x1,y2))
21566 types[1] = FFCOMBOTYPE(x1,y2);
21567
21568 types[2] = COMBOTYPE(x2,y1);
21569
21570 if(MAPFFCOMBO(x2,y1))
21571 types[2] = FFCOMBOTYPE(x2,y1);
21572
21573 types[3] = COMBOTYPE(x2,y2);
21574
21575 if(MAPFFCOMBO(x2,y2))
21576 types[3] = FFCOMBOTYPE(x2,y2);
21577
21578 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
21579 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
21580 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
21581
21582 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
21583 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
21584 water = typec;
21585 }
21586 13830 }
21587
21588
21589 // Pits have a bigger 'hitbox' than stairs...
21590 29093 x1 = tx+7;
21591 29093 x2 = tx+8;
21592 29093 y1 = ty+7+(bigHitbox?0:4);
21593 29093 y2 = ty+8+(bigHitbox?0:4);
21594
21595 29093 types[0] = COMBOTYPE(x1,y1);
21596 29093 cids[0] = MAPCOMBO(x1,y1);
21597
21598
2/2
✓ Branch 0 taken 28543 times.
✓ Branch 1 taken 550 times.
29093 if(MAPFFCOMBO(x1,y1))
21599 {
21600 550 types[0] = FFCOMBOTYPE(x1,y1);
21601 550 cids[0] = MAPFFCOMBO(x1,y1);
21602 550 }
21603
21604 29093 types[1] = COMBOTYPE(x1,y2);
21605 29093 cids[1] = MAPCOMBO(x1,y2);
21606
21607
2/2
✓ Branch 0 taken 28554 times.
✓ Branch 1 taken 539 times.
29093 if(MAPFFCOMBO(x1,y2))
21608 {
21609 539 types[1] = FFCOMBOTYPE(x1,y2);
21610 539 cids[1] = MAPFFCOMBO(x1,y2);
21611 539 }
21612 29093 types[2] = COMBOTYPE(x2,y1);
21613 29093 cids[2] = MAPCOMBO(x2,y1);
21614
21615
2/2
✓ Branch 0 taken 28566 times.
✓ Branch 1 taken 527 times.
29093 if(MAPFFCOMBO(x2,y1))
21616 {
21617 527 types[2] = FFCOMBOTYPE(x2,y1);
21618 527 cids[2] = MAPFFCOMBO(x2,y1);
21619 527 }
21620
21621 29093 types[3] = COMBOTYPE(x2,y2);
21622 29093 cids[3] = MAPCOMBO(x2,y2);
21623
21624
2/2
✓ Branch 0 taken 28576 times.
✓ Branch 1 taken 517 times.
29093 if(MAPFFCOMBO(x2,y2))
21625 {
21626 517 types[3] = FFCOMBOTYPE(x2,y2);
21627 517 cids[3] = MAPFFCOMBO(x2,y2);
21628 517 }
21629
21630
2/2
✓ Branch 0 taken 116372 times.
✓ Branch 1 taken 29093 times.
145465 for(int32_t i=0; i<4; i++)
21631 {
21632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21633 {
21634 types[i] = cNONE;
21635 continue;
21636 }
21637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 if(types[i]==cPIT)
21638 {
21639 index=0;
21640 warpsfx2 = combobuf[cids[i]].attribytes[0];
21641 }
21642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cPITB)
21643 {
21644 types[i]=cPIT;
21645 index=1;
21646 warpsfx2 = combobuf[cids[i]].attribytes[0];
21647 }
21648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116372 times.
116372 else if(types[i]==cPITC)
21649 {
21650 types[i]=cPIT;
21651 index=2;
21652 warpsfx2 = combobuf[cids[i]].attribytes[0];
21653 }
21654
1/2
✓ Branch 0 taken 116372 times.
✗ Branch 1 not taken.
116372 else if(types[i]==cPITD)
21655 {
21656 types[i]=cPIT;
21657 index=3;
21658 warpsfx2 = combobuf[cids[i]].attribytes[0];
21659 }
21660 116372 }
21661
21662
4/8
✓ Branch 0 taken 29093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29093 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29093 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 29093 times.
29093 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
21663 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21664 type=cPIT;
21665
21666 //
21667 // Time to act on our results for type, flag, flag2 and flag3...
21668 //
21669
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29093 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29093 if(type==cSAVE&&currscr<128)
21670 *ls=1;
21671
21672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29093 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29093 if(type==cSAVE2&&currscr<128)
21673 *ls=2;
21674
21675
6/8
✓ Branch 0 taken 29091 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 29009 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 29009 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 29009 times.
29093 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
21676 {
21677 84 fairycircle(REFILL_LIFE);
21678
21679
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1 times.
84 if(fairyclk!=0) return;
21680 1 }
21681
21682
4/8
✓ Branch 0 taken 29010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29010 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 29010 times.
29010 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
21683 {
21684 fairycircle(REFILL_MAGIC);
21685
21686 if(fairyclk!=0) return;
21687 }
21688
21689
4/8
✓ Branch 0 taken 29010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29010 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 29010 times.
29010 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
21690 {
21691 fairycircle(REFILL_ALL);
21692
21693 if(fairyclk!=0) return;
21694 }
21695
21696 // Just in case Hero was moved off of the fairy flag
21697
1/2
✓ Branch 0 taken 29010 times.
✗ Branch 1 not taken.
29010 if(refilling==REFILL_FAIRYDONE)
21698 {
21699 fairycircle(REFILL_NONE);
21700
21701 if(fairyclk!=0) return;
21702 }
21703
21704
4/8
✓ Branch 0 taken 29010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29010 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 29010 times.
29010 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
21705 {
21706 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
21707 win_game();
21708 return;
21709 }
21710
21711
2/4
✓ Branch 0 taken 29010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29010 times.
✗ Branch 3 not taken.
29010 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
21712 return;
21713
21714
2/4
✓ Branch 0 taken 29010 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29010 times.
29010 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
21715 {
21716
21717 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_bit(quest_rules,qr_TRIGGERSREPEAT))
21718 {
21719 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
21720 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
21721 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
21722
21723 if(type==cTRIGFLAG && canPermSecret())
21724 {
21725 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
21726
21727 hidden_entrance(0,true,false);
21728 }
21729 else
21730 {
21731 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21732 hidden_entrance(0,true,only16_31);
21733 }
21734 }
21735 }
21736
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 28998 times.
29010 else if(!didstrig)
21737 {
21738 28998 stepsecret = -1;
21739 28998 }
21740
21741 //Better? Dock collision
21742
21743 // Drown if:
21744 // * Water (obviously walkable),
21745 // * Quest Rule allows it,
21746 // * Not on stepladder,
21747 // * Not jumping,
21748 // * Not hovering,
21749 // * Not rafting,
21750 // * Not swallowed,
21751 // * Not a dried lake.
21752
21753 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
21754
21755
10/22
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 28730 times.
✓ Branch 2 taken 280 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 280 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 280 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 280 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 280 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 280 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 280 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 280 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
29010 if(water > 0 && ((get_bit(quest_rules,qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
21756 {
21757
4/8
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 278 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
280 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
21758 {
21759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!(ladderx+laddery)) drownCombo = water;
21760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (combobuf[water].usrflags&cflag1) Drown(1);
21761 2 else Drown();
21762
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(byte drown_sfx = combobuf[water].attribytes[4])
21763 sfx(drown_sfx, pan(int32_t(x)));
21764 2 }
21765
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1 times.
278 else if (!isSwimming())
21766 {
21767 1 SetSwim();
21768
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!IsSideSwim()) attackclk = charging = spins = 0;
21769 1 landswim=0;
21770 1 return;
21771 }
21772 279 }
21773
21774
21775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29009 times.
29009 if(type==cSTEP)
21776 {
21777 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
21778 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
21779 {
21780 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
21781
21782 if
21783 (
21784 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
21785 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
21786 && /*HEAVY*/
21787 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21788 )
21789
21790 {
21791 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
21792 tmpscr->data[stepnext]++;
21793
21794 }
21795
21796 if
21797 (
21798 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
21799 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21800 && /*HEAVY*/
21801 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21802 )
21803 {
21804 int32_t stepc = tmpscr->data[stepnext];
21805 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21806 for(int32_t k=0; k<176; k++)
21807 {
21808 if(tmpscr->data[k]==stepc)
21809 {
21810 tmpscr->data[k]++;
21811 }
21812 }
21813 }
21814
21815 if
21816 (
21817 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
21818 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21819 && /*HEAVY*/
21820 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21821 )
21822 {
21823 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21824 for(int32_t k=0; k<176; k++)
21825 {
21826 if(
21827 (combobuf[tmpscr->data[k]].type==cSTEP)||
21828 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
21829 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
21830 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
21831 )
21832 {
21833 tmpscr->data[k]++;
21834 }
21835 }
21836 }
21837 }
21838 }
21839
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29009 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29009 else if(type==cSTEPSFX && action == walking)
21840 {
21841 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
21842 }
21843 29009 else stepnext = -1;
21844
21845 29009 detail_int[0]=tx;
21846 29009 detail_int[1]=ty;
21847
21848
21849
6/8
✓ Branch 0 taken 28995 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 28994 times.
✓ Branch 4 taken 28991 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
29009 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
21850
3/6
✓ Branch 0 taken 28991 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28991 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28991 times.
✗ Branch 5 not taken.
28991 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
21851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28991 times.
28991 !(type==cDIVEWARP && isDiving()))
21852 28991 {
21853 RaftingStuff:
21854
2/2
✓ Branch 0 taken 28432 times.
✓ Branch 1 taken 559 times.
28991 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
21855 {
21856 559 bool doraft = true;
21857
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
21858 {
21859
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21860 {
21861 3 doraft = false;
21862 3 }
21863 3 }
21864 //if (mfRAFT)
21865 int32_t rafttypes[2];
21866 559 int32_t raftx1 = tx+6;
21867 559 int32_t raftx2 = tx+9;
21868 559 int32_t rafty = ty+11;
21869 int32_t raftflags[3];
21870 559 rafttypes[0]=rafttypes[1]=-1;
21871 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
21872 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
21873 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
21874
21875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21876 559 raftflags[0] = rafttypes[0];
21877
21878
21879 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
21880 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
21881
21882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21883 559 raftflags[1] = rafttypes[0];
21884
21885 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
21886 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
21887
21888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21889 559 raftflags[2] = rafttypes[0];
21890
21891
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
21892 {
21893
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
21894 {
21895 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
21896 {
21897 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
21898 {
21899 reset_swordcharge();
21900 action=rafting; FFCore.setHeroAction(rafting);
21901 raftclk=0;
21902 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21903 else sfx(tmpscr->secretsfx);
21904 }
21905 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21906 {
21907 for (int32_t i = 0; i < 4; ++i)
21908 {
21909 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
21910 {
21911 reset_swordcharge();
21912 action=rafting; FFCore.setHeroAction(rafting);
21913 raftclk=0;
21914 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21915 else sfx(tmpscr->secretsfx);
21916 dir = i;
21917 break;
21918 }
21919 }
21920 }
21921 }
21922 }
21923 1677 }
21924 559 }
21925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28991 times.
28991 if (RaftPass) return;
21926
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 28981 times.
✓ Branch 2 taken 10 times.
28991 switch(flag)
21927 {
21928 case mfDIVE_ITEM:
21929
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21930 {
21931 additem(x, y, tmpscr->catchall,
21932 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21933 sfx(tmpscr->secretsfx);
21934 }
21935
21936 10 return;
21937
21938 case mfRAFT:
21939 case mfRAFT_BRANCH:
21940
21941 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
21942 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
21943 {
21944 bool doraft = true;
21945 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
21946 {
21947 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21948 {
21949 doraft = false;
21950 }
21951 }
21952 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
21953 {
21954 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
21955 {
21956 reset_swordcharge();
21957 action=rafting; FFCore.setHeroAction(rafting);
21958 raftclk=0;
21959 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21960 else sfx(tmpscr->secretsfx);
21961 }
21962 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21963 {
21964 for (int32_t i = 0; i < 4; ++i)
21965 {
21966 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
21967 {
21968 reset_swordcharge();
21969 action=rafting; FFCore.setHeroAction(rafting);
21970 raftclk=0;
21971 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21972 else sfx(tmpscr->secretsfx);
21973 dir = i;
21974 break;
21975 }
21976 }
21977 }
21978 }
21979 }
21980
21981 return;
21982
21983 default:
21984 28981 break;
21985 //return;
21986 }
21987
21988
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 28981 times.
✗ Branch 2 not taken.
28981 switch(flag2)
21989 {
21990 case mfDIVE_ITEM:
21991 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21992 {
21993 additem(x, y, tmpscr->catchall,
21994 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21995 sfx(tmpscr->secretsfx);
21996 }
21997
21998 return;
21999
22000 case mfRAFT:
22001 case mfRAFT_BRANCH:
22002
22003 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
22004 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
22005 {
22006 bool doraft = true;
22007 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
22008 {
22009 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
22010 {
22011 doraft = false;
22012 }
22013 }
22014 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
22015 {
22016 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
22017 {
22018 reset_swordcharge();
22019 action=rafting; FFCore.setHeroAction(rafting);
22020 raftclk=0;
22021 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22022 else sfx(tmpscr->secretsfx);
22023 }
22024 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22025 {
22026 for (int32_t i = 0; i < 4; ++i)
22027 {
22028 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
22029 {
22030 reset_swordcharge();
22031 action=rafting; FFCore.setHeroAction(rafting);
22032 raftclk=0;
22033 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22034 else sfx(tmpscr->secretsfx);
22035 dir = i;
22036 break;
22037 }
22038 }
22039 }
22040 }
22041 }
22042
22043 return;
22044
22045 default:
22046 28981 break;
22047 //return;
22048 }
22049
22050
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 28981 times.
✗ Branch 2 not taken.
28981 switch(flag3)
22051 {
22052 case mfDIVE_ITEM:
22053 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
22054 {
22055 additem(x, y, tmpscr->catchall,
22056 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22057 sfx(tmpscr->secretsfx);
22058 }
22059
22060 return;
22061
22062 case mfRAFT:
22063 case mfRAFT_BRANCH:
22064
22065 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
22066 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
22067 {
22068 bool doraft = true;
22069 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
22070 {
22071 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
22072 {
22073 doraft = false;
22074 }
22075 }
22076 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
22077 {
22078 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
22079 {
22080 reset_swordcharge();
22081 action=rafting; FFCore.setHeroAction(rafting);
22082 raftclk=0;
22083 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22084 else sfx(tmpscr->secretsfx);
22085 }
22086 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22087 {
22088 for (int32_t i = 0; i < 4; ++i)
22089 {
22090 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
22091 {
22092 reset_swordcharge();
22093 action=rafting; FFCore.setHeroAction(rafting);
22094 raftclk=0;
22095 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22096 else sfx(tmpscr->secretsfx);
22097 dir = i;
22098 break;
22099 }
22100 }
22101 }
22102 }
22103 }
22104
22105 return;
22106
22107 default:
22108 28981 return;
22109 }
22110 }
22111
22112
22113 18 int32_t t=(currscr<128)?0:1;
22114
22115
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
22116
22117 //don't do this for canceled warps -DD
22118 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
22119 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
22120 {
22121 draw_screen(tmpscr);
22122 advanceframe(true);
22123 }*/
22124
22125 18 bool skippedaframe=false;
22126
22127
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
18 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
22128 {
22129 // Stop music only if:
22130 // * entering a Guy Cave
22131 // * warping to a DMap whose music is different.
22132
22133 18 int32_t tdm = tmpscr[t].tilewarpdmap[index];
22134
22135
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tmpscr[t].tilewarptype[index]<=wtPASS)
22136 {
22137
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
12 if((DMaps[currdmap].flags&dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
22138 10 music_stop();
22139 12 }
22140 else
22141 {
22142
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 if(zcmusic!=NULL)
22143 {
22144
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 if(strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
22145
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 (zcmusic->type==ZCMF_GME && zcmusic->track!=DMaps[tdm].tmusictrack))
22146 1 music_stop();
22147 1 }
22148
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if(DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi-ZC_MIDI_COUNT+4) &&
22149 5 TheMaps[(DMaps[tdm].map*MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi-ZC_MIDI_COUNT+4))
22150 5 music_stop();
22151 }
22152
22153 18 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
22154
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
18 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
22155 16 ? false : COOLSCROLL);
22156
22157 18 FFCore.warpScriptCheck();
22158 18 draw_screen(tmpscr);
22159 18 advanceframe(true);
22160
22161 18 skippedaframe=true;
22162
22163
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17 times.
18 if(type==cCAVE2) walkup2(opening);
22164
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 14 times.
17 else if(type==cCAVE) walkdown(opening);
22165 18 }
22166
22167
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(type==cPIT)
22168 {
22169 didpit=true;
22170 pitx=x;
22171 pity=y;
22172 warp_sound = warpsfx2;
22173 }
22174
22175
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
22176
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
22177 {
22178 if(!skippedaframe)
22179 {
22180 FFCore.warpScriptCheck();
22181 draw_screen(tmpscr);
22182 advanceframe(true);
22183 }
22184
22185 // "take any road you want"
22186 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
22187 int32_t code = WARPCODE(currdmap,homescr,dw);
22188
22189 if(code>-1)
22190 {
22191 bool changedlevel = false;
22192 bool changeddmap = false;
22193 if(currdmap != code>>8)
22194 {
22195 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22196 changeddmap = true;
22197 }
22198 if(dlevel != DMaps[code>>8].level)
22199 {
22200 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22201 changedlevel = true;
22202 }
22203 currdmap = code>>8;
22204 dlevel = DMaps[currdmap].level;
22205 if(changeddmap)
22206 {
22207 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22208 }
22209 if(changedlevel)
22210 {
22211 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22212 }
22213
22214 currmap = DMaps[currdmap].map;
22215 homescr = (code&0xFF) + DMaps[currdmap].xoff;
22216 init_dmap();
22217
22218 if(canPermSecret())
22219 setmapflag(mSECRET);
22220 }
22221
22222 if(specialcave==STAIRCAVE) exitcave();
22223
22224 return;
22225 }
22226
22227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(type==cRESET)
22228 {
22229 if(!skippedaframe)
22230 {
22231 FFCore.warpScriptCheck();
22232 draw_screen(tmpscr);
22233 advanceframe(true);
22234 }
22235
22236 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
22237
22238 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
22239
22240 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
22241
22242 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
22243
22244 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
22245
22246 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
22247
22248 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
22249
22250 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
22251
22252 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
22253
22254 if(isdungeon())
22255 {
22256 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
22257
22258 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
22259
22260 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
22261
22262 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
22263 }
22264
22265 didpit=true;
22266 pitx=x;
22267 pity=y;
22268 sdir=dir;
22269 dowarp(4,0, warpsfx2);
22270 }
22271 else
22272 {
22273
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
22274 {
22275 FFCore.warpScriptCheck();
22276 draw_screen(tmpscr);
22277 advanceframe(true);
22278 }
22279
22280 18 sdir = dir;
22281 18 dowarp(0,index, warpsfx2);
22282 }
22283 79833 }
22284
22285 int32_t selectWlevel(int32_t d)
22286 {
22287 if(TriforceCount()==0)
22288 return 0;
22289
22290 word l = game->get_wlevel();
22291
22292 do
22293 {
22294 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
22295 break;
22296 else if(d<0)
22297 l = (l==0) ? 7 : l-1;
22298 else
22299 l = (l==7) ? 0 : l+1;
22300 }
22301 while(!(game->lvlitems[l+1] & liTRIFORCE));
22302
22303 game->set_wlevel(l);
22304 return l;
22305 }
22306
22307 // Would someone tell the Dodongos to shut their yaps?!
22308 124 void kill_enemy_sfx()
22309 {
22310
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 144 times.
268 for(int32_t i=0; i<guys.Count(); i++)
22311 {
22312
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 64 times.
144 if(((enemy*)guys.spr(i))->bgsfx)
22313 64 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
22314 144 }
22315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
22316
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(tmpscr->room==rGANON)
22317 stop_sfx(WAV_ROAR);
22318 124 }
22319
22320 675 bool HeroClass::HasHeavyBoots()
22321 {
22322
2/2
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 172800 times.
173475 for ( int32_t q = 0; q < MAXITEMS; ++q )
22323 {
22324
5/6
✓ Branch 0 taken 1999 times.
✓ Branch 1 taken 170801 times.
✓ Branch 2 taken 649 times.
✓ Branch 3 taken 1350 times.
✓ Branch 4 taken 649 times.
✗ Branch 5 not taken.
172800 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
22325 172800 }
22326 675 return false;
22327 675 }
22328
22329 const char *roomtype_string[rMAX] =
22330 {
22331 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
22332 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
22333 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
22334 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
22335 };
22336
22337 60 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
22338 {
22339 60 byte reposition_sword_postwarp = 0;
22340
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(index<0)
22341 {
22342 return false;
22343 }
22344 60 is_warping = true;
22345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
22346 {
22347 weapon *swd=NULL;
22348 swd = (weapon*)Lwpns.spr(q);
22349 if(swd->id == (attack==wSword ? wSword : wWand))
22350 {
22351 Lwpns.del(q);
22352 }
22353 }
22354
22355 60 attackclk = charging = spins = tapping = 0;
22356 60 attack = none;
22357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if ( warp_sound > 0 ) warpsfx = warp_sound;
22358 60 warp_sound = 0;
22359 60 word wdmap=0;
22360 60 byte wscr=0,wtype=0,t=0;
22361 60 bool overlay=false;
22362 60 t=(currscr<128)?0:1;
22363 60 int32_t wrindex = 0;
22364 60 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
22365
22366 // Drawing commands probably shouldn't carry over...
22367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if ( !get_bit(quest_rules,qr_SCRIPTDRAWSINWARPS) )
22368 60 script_drawing_commands.Clear();
22369
22370
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
60 switch(type)
22371 {
22372 case 0: // tile warp
22373 18 wtype = tmpscr[t].tilewarptype[index];
22374 18 wdmap = tmpscr[t].tilewarpdmap[index];
22375 18 wscr = tmpscr[t].tilewarpscr[index];
22376 18 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
22377 18 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
22378 18 break;
22379
22380 case 1: // side warp
22381 42 wtype = tmpscr[t].sidewarptype[index];
22382 42 wdmap = tmpscr[t].sidewarpdmap[index];
22383 42 wscr = tmpscr[t].sidewarpscr[index];
22384 42 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
22385 42 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
22386 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
22387 //there is no doscript for screen scripts. They run like ffcs.
22388
22389 42 break;
22390
22391 case 2: // whistle warp
22392 {
22393 wtype = wtWHISTLE;
22394 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
22395 int32_t level=0;
22396
22397 if(blowcnt==0)
22398 level = selectWlevel(0);
22399 else
22400 {
22401 for(int32_t i=0; i<abs(blowcnt); i++)
22402 level = selectWlevel(blowcnt);
22403 }
22404
22405 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
22406 {
22407 level %= QMisc.warp[wind].size;
22408 game->set_wlevel(level);
22409 }
22410
22411 wdmap = QMisc.warp[wind].dmap[level];
22412 wscr = QMisc.warp[wind].scr[level];
22413 }
22414 break;
22415
22416 case 3:
22417 wtype = wtIWARP;
22418 wdmap = cheat_goto_dmap;
22419 wscr = cheat_goto_screen;
22420 break;
22421
22422 case 4:
22423 wtype = wtIWARP;
22424 wdmap = currdmap;
22425 wscr = homescr-DMaps[currdmap].xoff;
22426 break;
22427 }
22428
22429 60 bool intradmap = (wdmap == currdmap);
22430 60 int32_t olddmap = currdmap;
22431 60 rehydratelake(type!=wtSCROLL);
22432
22433
5/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 37 times.
60 switch(wtype)
22434 {
22435 case wtCAVE:
22436 {
22437 // cave/item room
22438 11 ALLOFF();
22439 11 homescr=currscr;
22440 11 currscr=0x80;
22441
22442
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if(DMaps[currdmap].flags&dmfCAVES) // cave
22443 {
22444 10 music_stop();
22445 10 kill_sfx();
22446
22447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(tmpscr->room==rWARP)
22448 {
22449 currscr=0x81;
22450 specialcave = STAIRCAVE;
22451 }
22452 10 else specialcave = GUYCAVE;
22453
22454 //lighting(2,dir);
22455 10 lighting(false, true);
22456 10 loadlvlpal(10);
22457
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
15 bool b2 = COOLSCROLL&&
22458
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
5 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
22459
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
22460
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
22461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
22462 10 blackscr(30,b2?false:true);
22463 10 loadscr(0,wdmap,currscr,up,false);
22464 10 loadscr(1,wdmap,homescr,up,false);
22465 //preloaded freeform combos
22466 10 ffscript_engine(true);
22467 10 putscr(scrollbuf,0,0,tmpscr);
22468 10 putscrdoors(scrollbuf,0,0,tmpscr);
22469 10 dir=up;
22470 10 x=112;
22471 10 y=160;
22472
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(didpit)
22473 {
22474 didpit=false;
22475 x=pitx;
22476 y=pity;
22477 }
22478
22479 10 reset_hookshot();
22480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(reposition_sword_postwarp)
22481 {
22482 weapon *swd=NULL;
22483 for(int32_t i=0; i<Lwpns.Count(); i++)
22484 {
22485 swd = (weapon*)Lwpns.spr(i);
22486
22487 if(swd->id == (attack==wSword ? wSword : wWand))
22488 {
22489 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22490 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22491 positionSword(swd,item_id);
22492 break;
22493 }
22494 }
22495 }
22496 10 stepforward(diagonalMovement?5:6, false);
22497 10 }
22498 else // item room
22499 {
22500 1 specialcave = ITEMCELLAR;
22501 1 map_bkgsfx(false);
22502 1 kill_enemy_sfx();
22503 1 draw_screen(tmpscr,false);
22504
22505 //unless the room is already dark, fade to black
22506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!darkroom)
22507 {
22508 1 darkroom = true;
22509 1 fade(DMaps[currdmap].color,true,false);
22510 1 }
22511
22512 1 blackscr(30,true);
22513 1 loadscr(0,wdmap,currscr,down,false);
22514 1 loadscr(1,wdmap,homescr,-1,false);
22515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( dontdraw < 2 ) { dontdraw=1; }
22516 1 draw_screen(tmpscr);
22517 1 fade(11,true,true);
22518 1 darkroom = false;
22519 1 dir=down;
22520 1 x=48;
22521 1 y=0;
22522
22523 // is this didpit check necessary?
22524
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(didpit)
22525 {
22526 didpit=false;
22527 x=pitx;
22528 y=pity;
22529 }
22530
22531 1 reset_hookshot();
22532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(reposition_sword_postwarp)
22533 {
22534 weapon *swd=NULL;
22535 for(int32_t i=0; i<Lwpns.Count(); i++)
22536 {
22537 swd = (weapon*)Lwpns.spr(i);
22538
22539 if(swd->id == (attack==wSword ? wSword : wWand))
22540 {
22541 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22542 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22543 positionSword(swd,item_id);
22544 break;
22545 }
22546 }
22547 }
22548 1 lighting(false, true);
22549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( dontdraw < 2 ) { dontdraw=0; }
22550 1 stepforward(diagonalMovement?16:18, false);
22551 }
22552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC)) playLevelMusic();
22553 11 break;
22554 }
22555
22556 case wtPASS: // passageway
22557 {
22558 1 map_bkgsfx(false);
22559 1 kill_enemy_sfx();
22560 1 ALLOFF();
22561 //play sound
22562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
22563 1 homescr=currscr;
22564 1 currscr=0x81;
22565 1 specialcave = PASSAGEWAY;
22566 1 byte warpscr2 = wscr + DMaps[wdmap].xoff;
22567 1 draw_screen(tmpscr,false);
22568
22569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!get_bit(quest_rules, qr_NEW_DARKROOM))
22570 {
22571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!darkroom)
22572 1 fade(DMaps[currdmap].color,true,false);
22573
22574 1 darkroom=true;
22575 1 }
22576 1 blackscr(30,true);
22577 1 loadscr(0,wdmap,currscr,down,false);
22578 1 loadscr(1,wdmap,homescr,-1,false);
22579 //preloaded freeform combos
22580 1 ffscript_engine(true);
22581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( dontdraw < 2 ) { dontdraw=1; }
22582 1 draw_screen(tmpscr);
22583 1 lighting(false, true);
22584 1 dir=down;
22585 1 x=48;
22586
22587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if((homescr&15) > (warpscr2&15))
22588 {
22589 1 x=192;
22590 1 }
22591
22592
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if((homescr&15) == (warpscr2&15))
22593 {
22594 if((currscr>>4) > (warpscr2>>4))
22595 {
22596 x=192;
22597 }
22598 }
22599
22600 // is this didpit check necessary?
22601
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(didpit)
22602 {
22603 didpit=false;
22604 x=pitx;
22605 y=pity;
22606 }
22607
22608 1 y=0;
22609 1 set_respawn_point();
22610 1 trySideviewLadder();
22611 1 reset_hookshot();
22612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(reposition_sword_postwarp)
22613 {
22614 weapon *swd=NULL;
22615 for(int32_t i=0; i<Lwpns.Count(); i++)
22616 {
22617 swd = (weapon*)Lwpns.spr(i);
22618
22619 if(swd->id == (attack==wSword ? wSword : wWand))
22620 {
22621 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22622 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22623 positionSword(swd,item_id);
22624 break;
22625 }
22626 }
22627 }
22628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( dontdraw < 2 ) { dontdraw=0; }
22629 1 stepforward(diagonalMovement?16:18, false);
22630 1 newscr_clk=frame;
22631 1 activated_timed_warp=false;
22632 1 stepoutindex=index;
22633 1 stepoutscr = warpscr2;
22634 1 stepoutdmap = wdmap;
22635 1 stepoutwr=wrindex;
22636 }
22637 1 break;
22638
22639 case wtEXIT: // entrance/exit
22640 {
22641 8 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
22642 8 ALLOFF();
22643 8 music_stop();
22644 8 kill_sfx();
22645 8 blackscr(30,false);
22646 8 bool changedlevel = false;
22647 8 bool changeddmap = false;
22648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(currdmap != wdmap)
22649 {
22650 8 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22651 8 changeddmap = true;
22652 8 }
22653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(dlevel != DMaps[wdmap].level)
22654 {
22655 8 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22656 8 changedlevel = true;
22657 8 }
22658 8 dlevel = DMaps[wdmap].level;
22659 8 currdmap = wdmap;
22660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(changeddmap)
22661 {
22662 8 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22663 8 }
22664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(changedlevel)
22665 {
22666 8 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22667 8 }
22668
22669 8 currmap=DMaps[currdmap].map;
22670 8 init_dmap();
22671 8 update_subscreens(wdmap);
22672 8 loadfullpal();
22673 8 ringcolor(false);
22674 8 loadlvlpal(DMaps[currdmap].color);
22675 //lastentrance_dmap = currdmap;
22676 8 homescr = currscr = wscr + DMaps[currdmap].xoff;
22677 8 loadscr(0,currdmap,currscr,-1,overlay);
22678
22679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if((tmpscr->flags&fDARK) && !get_bit(quest_rules,qr_NEW_DARKROOM))
22680 {
22681 if(get_bit(quest_rules,qr_FADE))
22682 {
22683 interpolatedfade();
22684 }
22685 else
22686 {
22687 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
22688 }
22689
22690 darkroom=naturaldark=true;
22691 }
22692 else
22693 {
22694 8 darkroom=naturaldark=false;
22695 }
22696
22697 int32_t wrx,wry;
22698
22699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22700 {
22701 wrx=tmpscr->warpreturnx[0];
22702 wry=tmpscr->warpreturny[0];
22703 }
22704 else
22705 {
22706 8 wrx=tmpscr->warparrivalx;
22707 8 wry=tmpscr->warparrivaly;
22708 }
22709
22710
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
8 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22711 {
22712
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 if(dlevel)
22713 {
22714 5 lastentrance = currscr;
22715 5 }
22716 else
22717 {
22718 3 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22719 }
22720
22721 8 lastentrance_dmap = wdmap;
22722 8 }
22723
22724
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 if(dlevel)
22725 {
22726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22727 {
22728 x=tmpscr->warpreturnx[wrindex];
22729 y=tmpscr->warpreturny[wrindex];
22730 }
22731 else
22732 {
22733 5 x=tmpscr->warparrivalx;
22734 5 y=tmpscr->warparrivaly;
22735 }
22736 5 }
22737 else
22738 {
22739 3 x=tmpscr->warpreturnx[wrindex];
22740 3 y=tmpscr->warpreturny[wrindex];
22741 }
22742
22743
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(didpit)
22744 {
22745 didpit=false;
22746 x=pitx;
22747 y=pity;
22748 }
22749
22750 8 dir=down;
22751
22752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(x==0) dir=right;
22753
22754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(x==240) dir=left;
22755
22756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(y==0) dir=down;
22757
22758
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 if(y==160) dir=up;
22759
22760
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 if(dlevel)
22761 {
22762 // reset enemy kill counts
22763
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 5 times.
645 for(int32_t i=0; i<128; i++)
22764 {
22765 640 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
22766 640 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
22767 640 }
22768 5 }
22769
22770 8 markBmap(dir^1);
22771 //preloaded freeform combos
22772 8 ffscript_engine(true);
22773
22774 8 reset_hookshot();
22775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(reposition_sword_postwarp)
22776 {
22777 weapon *swd=NULL;
22778 for(int32_t i=0; i<Lwpns.Count(); i++)
22779 {
22780 swd = (weapon*)Lwpns.spr(i);
22781
22782 if(swd->id == (attack==wSword ? wSword : wWand))
22783 {
22784 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22785 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22786 positionSword(swd,item_id);
22787 break;
22788 }
22789 }
22790 }
22791
22792
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 if(isdungeon())
22793 {
22794 5 openscreen();
22795
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(get_bit(extra_rules, er_SHORTDGNWALK)==0 && get_bit(quest_rules, qr_SHORTDGNWALK)==0)
22796 5 stepforward(diagonalMovement?11:12, false);
22797 else
22798 // Didn't walk as far pre-1.93, and some quests depend on that
22799 stepforward(8, false);
22800 5 }
22801 else
22802 {
22803
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(!COOLSCROLL)
22804 2 openscreen();
22805
22806 3 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
22807 3 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22808 3 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
22809
22810
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
22811 {
22812 3 reset_pal_cycling();
22813 3 putscr(scrollbuf,0,0,tmpscr);
22814 3 putscrdoors(scrollbuf,0,0,tmpscr);
22815 3 walkup(COOLSCROLL);
22816 3 }
22817 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
22818 {
22819 reset_pal_cycling();
22820 putscr(scrollbuf,0,0,tmpscr);
22821 putscrdoors(scrollbuf,0,0,tmpscr);
22822 walkdown2(COOLSCROLL);
22823 }
22824 else if(COOLSCROLL)
22825 {
22826 openscreen();
22827 }
22828 }
22829
22830 8 show_subscreen_life=true;
22831 8 show_subscreen_numbers=true;
22832 8 playLevelMusic();
22833 8 currcset=DMaps[currdmap].color;
22834 8 dointro();
22835 8 set_respawn_point();
22836 8 trySideviewLadder();
22837
22838
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 8 times.
56 for(int32_t i=0; i<6; i++)
22839 48 visited[i]=-1;
22840
22841 8 break;
22842 }
22843
22844 case wtSCROLL: // scrolling warp
22845 {
22846 int32_t c = DMaps[currdmap].color;
22847 scrolling_map = currmap;
22848 currmap = DMaps[wdmap].map;
22849 update_subscreens(wdmap);
22850
22851 dlevel = DMaps[wdmap].level;
22852 //check if Hero has the map for the new location before updating the subscreen. ? -Z
22853 //This works only in one direction, if Hero had a map, to not having one.
22854 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
22855 update_subscreens(wdmap);
22856
22857 /*if ( has_item(itype_map, dlevel) )
22858 {
22859 //Blank the map during an intra-dmap scrolling warp.
22860 dlevel = -1; //a hack for the minimap. This works!! -Z
22861 }*/
22862
22863 // fix the scrolling direction, if it was a tile or instant warp
22864 if(type==0 || type>=3)
22865 {
22866 sdir = dir;
22867 }
22868
22869 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
22870 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
22871
22872 reset_hookshot();
22873 if(reposition_sword_postwarp)
22874 {
22875 weapon *swd=NULL;
22876 for(int32_t i=0; i<Lwpns.Count(); i++)
22877 {
22878 swd = (weapon*)Lwpns.spr(i);
22879
22880 if(swd->id == (attack==wSword ? wSword : wWand))
22881 {
22882 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22883 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22884 positionSword(swd,item_id);
22885 break;
22886 }
22887 }
22888 }
22889 if(!intradmap)
22890 {
22891 homescr = currscr = wscr + DMaps[wdmap].xoff;
22892 init_dmap();
22893
22894 int32_t wrx,wry;
22895
22896 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22897 {
22898 wrx=tmpscr->warpreturnx[0];
22899 wry=tmpscr->warpreturny[0];
22900 }
22901 else
22902 {
22903 wrx=tmpscr->warparrivalx;
22904 wry=tmpscr->warparrivaly;
22905 }
22906
22907 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!get_bit(quest_rules,qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22908 {
22909 if(dlevel)
22910 {
22911 lastentrance = currscr;
22912 }
22913 else
22914 {
22915 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22916 }
22917
22918 lastentrance_dmap = wdmap;
22919 }
22920 }
22921 if(DMaps[currdmap].color != c)
22922 {
22923 lighting(false, true);
22924 }
22925
22926 playLevelMusic();
22927 currcset=DMaps[currdmap].color;
22928 dointro();
22929 }
22930 break;
22931
22932 case wtWHISTLE: // whistle warp
22933 {
22934 scrolling_map = currmap;
22935 currmap = DMaps[wdmap].map;
22936 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
22937 reset_hookshot();
22938 currdmap=wdmap;
22939 dlevel=DMaps[currdmap].level;
22940 lighting(false, true);
22941 init_dmap();
22942
22943 playLevelMusic();
22944 currcset=DMaps[currdmap].color;
22945 dointro();
22946 action=inwind; FFCore.setHeroAction(inwind);
22947 int32_t wry;
22948
22949 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22950 wry=tmpscr->warpreturny[0];
22951 else wry=tmpscr->warparrivaly;
22952
22953 int32_t wrx;
22954
22955 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22956 wrx=tmpscr->warpreturnx[0];
22957 else wrx=tmpscr->warparrivalx;
22958
22959 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
22960 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
22961 whirlwind=255;
22962 whistleitem=-1;
22963 }
22964 break;
22965
22966 case wtIWARP:
22967 case wtIWARPBLK:
22968 case wtIWARPOPEN:
22969 case wtIWARPZAP:
22970 case wtIWARPWAVE: // insta-warps
22971 {
22972 3 bool old_192 = false;
22973
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_bit(quest_rules,qr_192b163_WARP))
22974 {
22975 if ( wtype == wtIWARPWAVE )
22976 {
22977 wtype = wtIWARPWAVE;
22978 old_192 = true;
22979 }
22980 if ( old_192 )
22981 {
22982 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
22983 didpit=false;
22984 update_subscreens();
22985 warp_sound = 0;
22986 is_warping = false;
22987 return false;
22988 }
22989 }
22990 //for determining whether to exit cave
22991 3 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
22992 3 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22993 3 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
22994
22995
5/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
5 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
22996
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
22997
22998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
22999 {
23000 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
23001 3 bool wasswimming = (action == swimming);
23002 3 int32_t olddiveclk = diveclk;
23003 3 ALLOFF();
23004
23005
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(wasswimming)
23006 {
23007 Hero.SetSwim();
23008 diveclk = olddiveclk;
23009 }
23010
23011 3 kill_sfx();
23012 3 }
23013 //play sound
23014
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
23015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(wtype==wtIWARPZAP)
23016 {
23017 zapout();
23018 }
23019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(wtype==wtIWARPWAVE)
23020 {
23021 //only draw Hero if he's not in a cave -DD
23022 wavyout(!cavewarp);
23023 }
23024
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 else if(wtype!=wtIWARP)
23025 {
23026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 bool b2 = COOLSCROLL&&cavewarp;
23027 1 blackscr(30,b2?false:true);
23028 1 }
23029
23030 3 int32_t c = DMaps[currdmap].color;
23031 3 bool changedlevel = false;
23032 3 bool changeddmap = false;
23033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(currdmap != wdmap)
23034 {
23035 3 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
23036 3 changeddmap = true;
23037 3 }
23038
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(dlevel != DMaps[wdmap].level)
23039 {
23040 1 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
23041 1 changedlevel = true;
23042 1 }
23043 3 dlevel = DMaps[wdmap].level;
23044 3 currdmap = wdmap;
23045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(changeddmap)
23046 {
23047 3 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23048 3 }
23049
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(changedlevel)
23050 {
23051 1 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23052 1 }
23053
23054 3 currmap = DMaps[currdmap].map;
23055 3 init_dmap();
23056 3 update_subscreens(wdmap);
23057
23058 3 ringcolor(false);
23059
23060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(DMaps[currdmap].color != c)
23061 3 loadlvlpal(DMaps[currdmap].color);
23062
23063 3 homescr = currscr = wscr + DMaps[currdmap].xoff;
23064
23065 3 lightingInstant(); // Also sets naturaldark
23066
23067 3 loadscr(0,currdmap,currscr,-1,overlay);
23068
23069 3 x = tmpscr->warpreturnx[wrindex];
23070 3 y = tmpscr->warpreturny[wrindex];
23071
23072
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(didpit)
23073 {
23074 didpit=false;
23075 x=pitx;
23076 y=pity;
23077 }
23078
23079 3 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23080 3 type2 = combobuf[MAPCOMBO(x,y)].type;
23081 3 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23082
23083
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(x==0) dir=right;
23084
23085
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(x==240) dir=left;
23086
23087
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(y==0) dir=down;
23088
23089
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(y==160) dir=up;
23090
23091 3 markBmap(dir^1);
23092
23093 3 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
23094
23095
2/16
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 3 times.
3 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
23096 {
23097 hopclk=0xFF;
23098 SetSwim();
23099 if (!IsSideSwim()) attackclk = charging = spins = 0;
23100 }
23101 else
23102 {
23103 3 action = none; FFCore.setHeroAction(none);
23104 }
23105 //preloaded freeform combos
23106 3 ffscript_engine(true);
23107
23108 3 putscr(scrollbuf,0,0,tmpscr);
23109 3 putscrdoors(scrollbuf,0,0,tmpscr);
23110
23111
4/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23112 {
23113 reset_pal_cycling();
23114 putscr(scrollbuf,0,0,tmpscr);
23115 putscrdoors(scrollbuf,0,0,tmpscr);
23116 walkup(COOLSCROLL);
23117 }
23118
4/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23119 {
23120 reset_pal_cycling();
23121 putscr(scrollbuf,0,0,tmpscr);
23122 putscrdoors(scrollbuf,0,0,tmpscr);
23123 walkdown2(COOLSCROLL);
23124 }
23125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(wtype==wtIWARPZAP)
23126 {
23127 zapin();
23128 }
23129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(wtype==wtIWARPWAVE)
23130 {
23131 wavyin();
23132 }
23133
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 else if(wtype==wtIWARPOPEN)
23134 {
23135 1 openscreen();
23136 1 }
23137
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(reposition_sword_postwarp)
23138 {
23139 weapon *swd=NULL;
23140 for(int32_t i=0; i<Lwpns.Count(); i++)
23141 {
23142 swd = (weapon*)Lwpns.spr(i);
23143
23144 if(swd->id == (attack==wSword ? wSword : wWand))
23145 {
23146 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23147 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23148 positionSword(swd,item_id);
23149 break;
23150 }
23151 }
23152 }
23153 3 show_subscreen_life=true;
23154 3 show_subscreen_numbers=true;
23155 3 playLevelMusic();
23156 3 currcset=DMaps[currdmap].color;
23157 3 dointro();
23158 3 set_respawn_point();
23159 3 trySideviewLadder();
23160 }
23161 3 break;
23162
23163
23164 case wtNOWARP:
23165 {
23166 37 bool old_192 = false;
23167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if (get_bit(quest_rules,qr_192b163_WARP))
23168 {
23169 wtype = wtIWARPWAVE;
23170 old_192 = true;
23171 }
23172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if ( old_192 )
23173 {
23174 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
23175 //for determining whether to exit cave
23176 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23177 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23178 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23179
23180 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
23181 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
23182
23183 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
23184 {
23185 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
23186 bool wasswimming = (action == swimming);
23187 int32_t olddiveclk = diveclk;
23188 ALLOFF();
23189
23190 if(wasswimming)
23191 {
23192 Hero.SetSwim();
23193 diveclk = olddiveclk;
23194 }
23195
23196 kill_sfx();
23197 }
23198 //play sound
23199 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
23200 if(wtype==wtIWARPZAP)
23201 {
23202 zapout();
23203 }
23204 else if(wtype==wtIWARPWAVE)
23205 {
23206 //only draw Hero if he's not in a cave -DD
23207 wavyout(!cavewarp);
23208 }
23209 else if(wtype!=wtIWARP)
23210 {
23211 bool b2 = COOLSCROLL&&cavewarp;
23212 blackscr(30,b2?false:true);
23213 }
23214
23215 int32_t c = DMaps[currdmap].color;
23216 bool changedlevel = false;
23217 bool changeddmap = false;
23218 if(currdmap != wdmap)
23219 {
23220 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
23221 changeddmap = true;
23222 }
23223 if(dlevel != DMaps[wdmap].level)
23224 {
23225 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
23226 changedlevel = true;
23227 }
23228 dlevel = DMaps[wdmap].level;
23229 currdmap = wdmap;
23230 if(changeddmap)
23231 {
23232 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23233 }
23234 if(changedlevel)
23235 {
23236 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23237 }
23238 currmap = DMaps[currdmap].map;
23239 init_dmap();
23240 update_subscreens(wdmap);
23241
23242 ringcolor(false);
23243
23244 if(DMaps[currdmap].color != c)
23245 loadlvlpal(DMaps[currdmap].color);
23246
23247 homescr = currscr = wscr + DMaps[currdmap].xoff;
23248
23249 lightingInstant(); // Also sets naturaldark
23250
23251 loadscr(0,currdmap,currscr,-1,overlay);
23252
23253 x = tmpscr->warpreturnx[wrindex];
23254 y = tmpscr->warpreturny[wrindex];
23255
23256 if(didpit)
23257 {
23258 didpit=false;
23259 x=pitx;
23260 y=pity;
23261 }
23262
23263 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23264 type2 = combobuf[MAPCOMBO(x,y)].type;
23265 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23266
23267 if(x==0) dir=right;
23268
23269 if(x==240) dir=left;
23270
23271 if(y==0) dir=down;
23272
23273 if(y==160) dir=up;
23274
23275 markBmap(dir^1);
23276
23277 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
23278 {
23279 hopclk=0xFF;
23280 SetSwim();
23281 if (!IsSideSwim()) attackclk = charging = spins = 0;
23282 }
23283 else
23284 {
23285 action = none;
23286 FFCore.setHeroAction(none);
23287 }
23288 //preloaded freeform combos
23289 ffscript_engine(true);
23290
23291 putscr(scrollbuf,0,0,tmpscr);
23292 putscrdoors(scrollbuf,0,0,tmpscr);
23293
23294 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23295 {
23296 reset_pal_cycling();
23297 putscr(scrollbuf,0,0,tmpscr);
23298 putscrdoors(scrollbuf,0,0,tmpscr);
23299 walkup(COOLSCROLL);
23300 }
23301 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23302 {
23303 reset_pal_cycling();
23304 putscr(scrollbuf,0,0,tmpscr);
23305 putscrdoors(scrollbuf,0,0,tmpscr);
23306 walkdown2(COOLSCROLL);
23307 }
23308 else if(wtype==wtIWARPZAP)
23309 {
23310 zapin();
23311 }
23312 else if(wtype==wtIWARPWAVE)
23313 {
23314 wavyin();
23315 }
23316 else if(wtype==wtIWARPOPEN)
23317 {
23318 openscreen();
23319 }
23320 if(reposition_sword_postwarp)
23321 {
23322 weapon *swd=NULL;
23323 for(int32_t i=0; i<Lwpns.Count(); i++)
23324 {
23325 swd = (weapon*)Lwpns.spr(i);
23326
23327 if(swd->id == (attack==wSword ? wSword : wWand))
23328 {
23329 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23330 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23331 positionSword(swd,item_id);
23332 break;
23333 }
23334 }
23335 }
23336 show_subscreen_life=true;
23337 show_subscreen_numbers=true;
23338 playLevelMusic();
23339 currcset=DMaps[currdmap].color;
23340 dointro();
23341 set_respawn_point();
23342 trySideviewLadder();
23343 break;
23344 }
23345 else
23346 {
23347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(reposition_sword_postwarp)
23348 {
23349 weapon *swd=NULL;
23350 for(int32_t i=0; i<Lwpns.Count(); i++)
23351 {
23352 swd = (weapon*)Lwpns.spr(i);
23353
23354 if(swd->id == (attack==wSword ? wSword : wWand))
23355 {
23356 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23357 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23358 positionSword(swd,item_id);
23359 break;
23360 }
23361 }
23362 }
23363 37 didpit=false;
23364 37 update_subscreens();
23365 37 warp_sound = 0;
23366 37 is_warping = false;
23367 37 return false;
23368 }
23369 }
23370 default:
23371 didpit=false;
23372 update_subscreens();
23373 warp_sound = 0;
23374 is_warping = false;
23375 if(reposition_sword_postwarp)
23376 {
23377 weapon *swd=NULL;
23378 for(int32_t i=0; i<Lwpns.Count(); i++)
23379 {
23380 swd = (weapon*)Lwpns.spr(i);
23381
23382 if(swd->id == (attack==wSword ? wSword : wWand))
23383 {
23384 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23385 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23386 positionSword(swd,item_id);
23387 break;
23388 }
23389 }
23390 }
23391 return false;
23392 }
23393
23394
23395
23396 // Stop Hero from drowning!
23397
3/6
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
23 if(action==drowning || action==lavadrowning || action==sidedrowning)
23398 {
23399 drownclk=0;
23400 drownclk=0;
23401 action=none; FFCore.setHeroAction(none);
23402 }
23403
23404 23 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
23405 // But keep him swimming if he ought to be!
23406 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
23407
3/12
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 23 times.
✗ Branch 11 not taken.
23 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_bit(quest_rules,qr_DROWN))
23408 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
23409 && (action!=inwind))
23410 {
23411 hopclk=0xFF;
23412 SetSwim();
23413 }
23414
23415 23 newscr_clk=frame;
23416 23 activated_timed_warp=false;
23417 23 eat_buttons();
23418
23419
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21 times.
23 if(wtype!=wtIWARP)
23420 21 attackclk=0;
23421
23422 23 didstuff=0;
23423 23 usecounts.clear();
23424 23 map_bkgsfx(true);
23425 23 loadside=dir^1;
23426 23 whistleclk=-1;
23427
23428
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if((z>0 || fakez>0) && isSideViewHero())
23429 {
23430 y-=z;
23431 y-=fakez;
23432 fakez=0;
23433 z=0;
23434 }
23435
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 else if(!isSideViewHero())
23436 {
23437 22 fall=0;
23438 22 fakefall=0;
23439 22 }
23440
23441 // If warping between top-down and sideview screens,
23442 // fix enemies that are carried over by Full Screen Warp
23443 23 const bool tmpscr_is_sideview = isSideViewHero();
23444
23445
3/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 1 times.
23 if(!wasSideview && tmpscr_is_sideview)
23446 {
23447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<guys.Count(); i++)
23448 {
23449 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
23450 {
23451 guys.spr(i)->y -= guys.spr(i)->z;
23452 guys.spr(i)->y -= guys.spr(i)->fakez;
23453 guys.spr(i)->z = 0;
23454 guys.spr(i)->fakez = 0;
23455 }
23456
23457 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23458 guys.spr(i)->yofs += 2;
23459 }
23460 1 }
23461
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22 else if(wasSideview && !tmpscr_is_sideview)
23462 {
23463 for(int32_t i=0; i<guys.Count(); i++)
23464 {
23465 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23466 guys.spr(i)->yofs -= 2;
23467 }
23468 }
23469
23470
5/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
23 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_bit(quest_rules, qr_DMAP_0_CONTINUE_BUG)))
23471 {
23472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(dlevel)
23473 {
23474 int32_t wrx,wry;
23475
23476 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
23477 {
23478 wrx=tmpscr->warpreturnx[0];
23479 wry=tmpscr->warpreturny[0];
23480 }
23481 else
23482 {
23483 wrx=tmpscr->warparrivalx;
23484 wry=tmpscr->warparrivaly;
23485 }
23486
23487 if((wtype == wtEXIT)
23488 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))))
23489 {
23490 if(!(wtype==wtSCROLL)||!(get_bit(quest_rules,qr_NOSCROLLCONTINUE)))
23491 {
23492 game->set_continue_scrn(homescr);
23493 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
23494 }
23495 else if(currdmap != game->get_continue_dmap())
23496 {
23497 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23498 }
23499 }
23500 else
23501 {
23502 if(currdmap != game->get_continue_dmap())
23503 {
23504 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23505 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
23506 }
23507 }
23508 }
23509 else
23510 {
23511 13 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23512 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
23513 }
23514
23515 13 game->set_continue_dmap(currdmap);
23516 13 lastentrance_dmap = currdmap;
23517 13 lastentrance = game->get_continue_scrn();
23518 //Z_message("continue_map = %d\n",game->get_continue_dmap());
23519 13 }
23520
23521
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(tmpscr->flags4&fAUTOSAVE)
23522 {
23523 save_game(true,0);
23524 }
23525
23526
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(tmpscr->flags6&fCONTINUEHERE)
23527 {
23528 lastentrance_dmap = currdmap;
23529 lastentrance = homescr;
23530 }
23531
23532 23 update_subscreens();
23533 23 verifyBothWeapons();
23534
23535
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 11 times.
23 if(wtype==wtCAVE)
23536 {
23537
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if(DMaps[currdmap].flags&dmfGUYCAVES)
23538 20 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
23539 10 (char *)moduledata.roomtype_names[tmpscr[1].room]);
23540 else
23541 1 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
23542 11 }
23543 24 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
23544
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
23 wtype==wtPASS ? "Passageway" :
23545
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3 times.
14 wtype==wtEXIT ? "Entrance/Exit" :
23546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 wtype==wtSCROLL ? "Scrolling Warp" :
23547 3 wtype==wtWHISTLE ? "Whistle Warp" :
23548 "Insta-Warp");
23549
23550 23 eventlog_mapflags();
23551
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(reposition_sword_postwarp)
23552 {
23553 weapon *swd=NULL;
23554 for(int32_t i=0; i<Lwpns.Count(); i++)
23555 {
23556 swd = (weapon*)Lwpns.spr(i);
23557
23558 if(swd->id == (attack==wSword ? wSword : wWand))
23559 {
23560 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23561 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23562 positionSword(swd,item_id);
23563 break;
23564 }
23565 }
23566 }
23567 23 FFCore.init_combo_doscript();
23568
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
23 if (!intradmap || get_bit(quest_rules, qr_WARPS_RESTART_DMAPSCRIPT))
23569 {
23570 23 FFScript::deallocateAllArrays(SCRIPT_DMAP, olddmap);
23571 23 FFCore.initZScriptDMapScripts();
23572 23 FFCore.initZScriptActiveSubscreenScript();
23573 23 }
23574 23 is_warping = false;
23575 23 return true;
23576 60 }
23577
23578 10 void HeroClass::exitcave()
23579 {
23580 10 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
23581 10 currscr=homescr;
23582 10 loadscr(0,currdmap,currscr,255,false); // bogus direction
23583 10 x = tmpscr->warpreturnx[0];
23584 10 y = tmpscr->warpreturny[0];
23585
23586
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(didpit)
23587 {
23588 didpit=false;
23589 x=pitx;
23590 y=pity;
23591 }
23592
23593
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(x+y == 0)
23594 x = y = 80;
23595
23596 10 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23597 10 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23598 10 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23599
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
15 bool b = COOLSCROLL &&
23600
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
5 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
23601
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
23602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
23603 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
23604 10 ALLOFF();
23605 10 blackscr(30,b?false:true);
23606 10 ringcolor(false);
23607 10 loadlvlpal(DMaps[currdmap].color);
23608 10 lighting(false, true);
23609 10 music_stop();
23610 10 kill_sfx();
23611 10 putscr(scrollbuf,0,0,tmpscr);
23612 10 putscrdoors(scrollbuf,0,0,tmpscr);
23613
23614
5/10
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
10 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23615 {
23616 9 walkup(COOLSCROLL);
23617 9 }
23618
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23619 {
23620 1 walkdown2(COOLSCROLL);
23621 1 }
23622
23623 10 show_subscreen_life=true;
23624 10 show_subscreen_numbers=true;
23625 10 playLevelMusic();
23626 10 currcset=DMaps[currdmap].color;
23627 10 dointro();
23628 10 newscr_clk=frame;
23629 10 activated_timed_warp=false;
23630 10 dir=down;
23631 10 set_respawn_point();
23632 10 eat_buttons();
23633 10 didstuff=0;
23634 10 usecounts.clear();
23635 10 map_bkgsfx(true);
23636 10 loadside=dir^1;
23637 10 }
23638
23639
23640 82 void HeroClass::stepforward(int32_t steps, bool adjust)
23641 {
23642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if ( FFCore.nostepforward ) return;
23643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
23644 82 zfix tx=x; //temp x
23645 82 zfix ty=y; //temp y
23646 82 zfix tstep(0); //temp single step distance
23647 82 zfix s(0); //calculated step distance for all steps
23648 82 z3step=2;
23649 82 int32_t sh=shiftdir;
23650 82 shiftdir=-1;
23651
23652
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 82 times.
1174 for(int32_t i=steps; i>0; --i)
23653 {
23654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if(diagonalMovement)
23655 {
23656 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23657 {
23658 tstep = 1.5;
23659 }
23660 else
23661 {
23662 tstep=z3step;
23663 z3step=(z3step%2)+1;
23664 }
23665 }
23666 else
23667 {
23668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
23669 {
23670 tstep = 1.5;
23671 }
23672 else
23673 {
23674
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 612 times.
1092 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
23675
23676
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 252 times.
✓ Branch 4 taken 360 times.
1092 switch(dir)
23677 {
23678 case up:
23679 372 ty-=tstep;
23680 372 break;
23681
23682 case down:
23683 108 ty+=tstep;
23684 108 break;
23685
23686 case left:
23687 252 tx-=tstep;
23688 252 break;
23689
23690 case right:
23691 360 tx+=tstep;
23692 360 break;
23693 }
23694 }
23695 }
23696
23697 1092 s+=tstep;
23698 1092 }
23699
23700 82 z3step=2;
23701
23702 82 x = x.getInt();
23703 82 y = y.getInt();
23704
2/2
✓ Branch 0 taken 1174 times.
✓ Branch 1 taken 82 times.
1256 while(s>=0)
23705 {
23706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1174 times.
1174 if(diagonalMovement)
23707 {
23708 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23709 {
23710 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23711 {
23712 walkable = false;
23713 shiftdir = -1;
23714 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23715 switch(tdir)
23716 {
23717 case left:
23718 --x;
23719 break;
23720 case right:
23721 ++x;
23722 break;
23723 case up:
23724 --y;
23725 break;
23726 case down:
23727 ++y;
23728 break;
23729 }
23730 }
23731 else
23732 {
23733 walkable=false;
23734 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23735 move(dir, 150);
23736 }
23737 }
23738 else
23739 {
23740 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23741 {
23742 s-=1.5;
23743 }
23744 else
23745 {
23746 s-=z3step;
23747 }
23748 walkable=true;
23749 move(dir, 150);
23750 }
23751
23752 shiftdir=-1;
23753 }
23754 else
23755 {
23756
3/6
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1174 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1174 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23757 {
23758 walkable=false;
23759 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23760 switch(tdir)
23761 {
23762 case left:
23763 --x;
23764 break;
23765 case right:
23766 ++x;
23767 break;
23768 case up:
23769 --y;
23770 break;
23771 case down:
23772 ++y;
23773 break;
23774 }
23775 }
23776 else
23777 {
23778
2/4
✓ Branch 0 taken 1174 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1174 times.
1174 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23779 {
23780 s-=1.5;
23781 }
23782
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 654 times.
1174 else if(dir<left)
23783 {
23784 520 s-=lsteps[y.getInt()&7];
23785 520 }
23786 else
23787 {
23788 654 s-=lsteps[x.getInt()&7];
23789 }
23790
23791 1174 move(dir, 150);
23792 }
23793 }
23794
23795
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 82 times.
1174 if(s<0)
23796 {
23797 // Not quite sure how this is actually supposed to work.
23798 // There have to be two cases for each direction or Hero
23799 // either walks too far onto the screen or may get stuck
23800 // going through walk-through walls.
23801
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 17 times.
✓ Branch 4 taken 25 times.
82 switch(dir)
23802 {
23803 case up:
23804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(y<8) // Leaving the screen
23805 y+=s;
23806 else // Entering the screen
23807 33 y-=s;
23808
23809 33 break;
23810
23811 case down:
23812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(y>152)
23813 y-=s;
23814 else
23815 7 y+=s;
23816
23817 7 break;
23818
23819 case left:
23820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(x<8)
23821 x+=s;
23822 else
23823 17 x-=s;
23824
23825 17 break;
23826
23827 case right:
23828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(x>=232)
23829 x-=s;
23830 else
23831 25 x+=s;
23832
23833 25 break;
23834 }
23835 82 }
23836
23837
23838 1174 draw_screen(tmpscr);
23839
1/2
✓ Branch 0 taken 1174 times.
✗ Branch 1 not taken.
1174 if (canSideviewLadder()) setOnSideviewLadder(true);
23840 1174 advanceframe(true);
23841
23842
1/2
✓ Branch 0 taken 1174 times.
✗ Branch 1 not taken.
1174 if(Quit)
23843 return;
23844 }
23845
4/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 50 times.
82 if(dir==right||dir==down)
23846 {
23847 32 x=int32_t(x);
23848 32 y=int32_t(y);
23849 32 }
23850 else
23851 {
23852 50 x = x.getInt();
23853 50 y = y.getInt();
23854 }
23855 82 set_respawn_point();
23856 82 draw_screen(tmpscr);
23857 82 eat_buttons();
23858 82 shiftdir=sh;
23859 82 }
23860
23861 14 void HeroClass::walkdown(bool opening) //entering cave
23862 {
23863
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
14 if(opening)
23864 {
23865 7 close_black_opening(x+8, y+8+playing_field_offset, false);
23866 7 }
23867
23868 14 hclk=0;
23869 14 stop_item_sfx(itype_brang);
23870 14 sfx(WAV_STAIRS,pan(x.getInt()));
23871 14 clk=0;
23872 // int32_t cmby=(y.getInt()&0xF0)+16;
23873 // Fix Hero's position to the grid
23874 14 y=y.getInt()&0xF0;
23875 14 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23876 14 attack=wNone;
23877 14 attackid=-1;
23878 14 reset_swordcharge();
23879 14 climb_cover_x=x.getInt()&0xF0;
23880 14 climb_cover_y=(y.getInt()&0xF0)+16;
23881
23882 14 guys.clear();
23883 14 chainlinks.clear();
23884 14 Lwpns.clear();
23885 14 Ewpns.clear();
23886 14 items.clear();
23887
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 896 times.
910 for(int32_t i=0; i<64; i++)
23888 {
23889 896 herostep();
23890
23891
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 896 times.
896 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23892 hero_count=(hero_count+1)%16;
23893
23894
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 224 times.
896 if((i&3)==3)
23895 224 ++y;
23896
23897 896 draw_screen(tmpscr);
23898 896 advanceframe(true);
23899
23900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 896 times.
896 if(Quit)
23901 break;
23902 896 }
23903
23904 14 action=none; FFCore.setHeroAction(none);
23905 14 }
23906
23907 1 void HeroClass::walkdown2(bool opening) //exiting cave 2
23908 {
23909 1 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23910
23911
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
23912 y-=16;
23913
23914 1 dir=down;
23915 // Fix Hero's position to the grid
23916 1 y=y.getInt()&0xF0;
23917 1 z=fakez=fall=fakefall=0;
23918
23919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(opening)
23920 {
23921 1 open_black_opening(x+8, y+8+playing_field_offset+16, false);
23922 1 }
23923
23924 1 hclk=0;
23925 1 stop_item_sfx(itype_brang);
23926 1 sfx(WAV_STAIRS,pan(x.getInt()));
23927 1 clk=0;
23928 // int32_t cmby=y.getInt()&0xF0;
23929 1 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
23930 1 attack=wNone;
23931 1 attackid=-1;
23932 1 reset_swordcharge();
23933 1 climb_cover_x=x.getInt()&0xF0;
23934 1 climb_cover_y=y.getInt()&0xF0;
23935
23936 1 guys.clear();
23937 1 chainlinks.clear();
23938 1 Lwpns.clear();
23939 1 Ewpns.clear();
23940 1 items.clear();
23941
23942
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 for(int32_t i=0; i<64; i++)
23943 {
23944 64 herostep();
23945
23946
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23947 hero_count=(hero_count+1)%16;
23948
23949
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 if((i&3)==3)
23950 16 ++y;
23951
23952 64 draw_screen(tmpscr);
23953 64 advanceframe(true);
23954
23955
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(Quit)
23956 break;
23957 64 }
23958
23959 1 action=none; FFCore.setHeroAction(none);
23960 1 }
23961
23962 12 void HeroClass::walkup(bool opening) //exiting cave
23963 {
23964 12 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23965
23966
2/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
23967 y+=16;
23968
23969 // Fix Hero's position to the grid
23970 12 y=y.getInt()&0xF0;
23971 12 z=fakez=fall=fakefall=0;
23972
23973
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 5 times.
12 if(opening)
23974 {
23975 5 open_black_opening(x+8, y+8+playing_field_offset-16, false);
23976 5 }
23977
23978 12 hclk=0;
23979 12 stop_item_sfx(itype_brang);
23980 12 sfx(WAV_STAIRS,pan(x.getInt()));
23981 12 dir=down;
23982 12 clk=0;
23983 // int32_t cmby=y.getInt()&0xF0;
23984 12 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23985 12 attack=wNone;
23986 12 attackid=-1;
23987 12 reset_swordcharge();
23988 12 climb_cover_x=x.getInt()&0xF0;
23989 12 climb_cover_y=y.getInt()&0xF0;
23990
23991 12 guys.clear();
23992 12 chainlinks.clear();
23993 12 Lwpns.clear();
23994 12 Ewpns.clear();
23995 12 items.clear();
23996
23997
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 768 times.
780 for(int32_t i=0; i<64; i++)
23998 {
23999 768 herostep();
24000
24001
2/4
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 768 times.
768 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24002 hero_count=(hero_count+1)%16;
24003
24004
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 if((i&3)==0)
24005 192 --y;
24006
24007 768 draw_screen(tmpscr);
24008 768 advanceframe(true);
24009
24010
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(Quit)
24011 break;
24012 768 }
24013 12 map_bkgsfx(true);
24014 12 loadside=dir^1;
24015 12 action=none; FFCore.setHeroAction(none);
24016 12 }
24017
24018 1 void HeroClass::walkup2(bool opening) //entering cave2
24019 {
24020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(opening)
24021 {
24022 1 close_black_opening(x+8, y+8+playing_field_offset, false);
24023 1 }
24024
24025 1 hclk=0;
24026 1 stop_item_sfx(itype_brang);
24027 1 sfx(WAV_STAIRS,pan(x.getInt()));
24028 1 dir=up;
24029 1 clk=0;
24030 // int32_t cmby=y.getInt()&0xF0;
24031 1 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
24032 1 attack=wNone;
24033 1 attackid=-1;
24034 1 reset_swordcharge();
24035 1 climb_cover_x=x.getInt()&0xF0;
24036 1 climb_cover_y=(y.getInt()&0xF0)-16;
24037
24038 1 guys.clear();
24039 1 chainlinks.clear();
24040 1 Lwpns.clear();
24041 1 Ewpns.clear();
24042 1 items.clear();
24043
24044
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 for(int32_t i=0; i<64; i++)
24045 {
24046 64 herostep();
24047
24048
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24049 hero_count=(hero_count+1)%16;
24050
24051
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 if((i&3)==0)
24052 16 --y;
24053
24054 64 draw_screen(tmpscr);
24055 64 advanceframe(true);
24056
24057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(Quit)
24058 break;
24059 64 }
24060 1 map_bkgsfx(true);
24061 1 loadside=dir^1;
24062 1 action=none; FFCore.setHeroAction(none);
24063 1 }
24064
24065 1 void HeroClass::stepout() // Step out of item cellars and passageways
24066 {
24067 1 int32_t sc = specialcave; // This gets erased by ALLOFF()
24068 1 ALLOFF();
24069 1 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
24070 1 map_bkgsfx(false);
24071 1 kill_enemy_sfx();
24072 1 draw_screen(tmpscr,false);
24073 1 fade(sc>=GUYCAVE?10:11,true,false);
24074 1 blackscr(30,true);
24075 1 ringcolor(false);
24076
24077
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
24078 {
24079 1 currdmap=stepoutdmap;
24080 1 currmap=DMaps[currdmap].map;
24081 1 dlevel=DMaps[currdmap].level;
24082
24083 //we might have just left a passage, so be sure to update the CSet record -DD
24084 1 currcset=DMaps[currdmap].color;
24085
24086 1 init_dmap();
24087 1 homescr=stepoutscr;
24088 1 }
24089
24090 1 currscr=homescr;
24091 1 loadscr(0,currdmap,currscr,255,false); // bogus direction
24092 1 draw_screen(tmpscr,false);
24093
24094
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(get_bit(quest_rules, qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
24095 {
24096 1 darkroom = naturaldark = false;
24097 1 fade(DMaps[currdmap].color,true,true);
24098 1 }
24099 else
24100 {
24101 darkroom = naturaldark = true;
24102
24103 if(get_bit(quest_rules,qr_FADE))
24104 {
24105 interpolatedfade();
24106 }
24107 else
24108 {
24109 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24110 }
24111 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
24112 si+=3*48;
24113
24114 for(int32_t i=0; i<16; i++)
24115 {
24116 RAMpal[CSET(9)+i] = _RGB(si);
24117 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
24118 si+=3;
24119 }
24120 }
24121
24122 1 x = tmpscr->warpreturnx[stepoutwr];
24123 1 y = tmpscr->warpreturny[stepoutwr];
24124
24125
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(didpit)
24126 {
24127 didpit=false;
24128 x=pitx;
24129 y=pity;
24130 }
24131
24132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(x+y == 0)
24133 x = y = 80;
24134
24135 1 dir=down;
24136
24137 1 set_respawn_point();
24138
24139 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
24140 1 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
24141
24142
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
24143 {
24144 walkup(false);
24145 }
24146
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
24147 {
24148 walkdown2(false);
24149 }
24150
24151 1 newscr_clk=frame;
24152 1 activated_timed_warp=false;
24153 1 didstuff=0;
24154 1 usecounts.clear();
24155 1 eat_buttons();
24156 1 markBmap(-1);
24157 1 map_bkgsfx(true);
24158
24159
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!get_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC))
24160 {
24161 music_stop();
24162 playLevelMusic();
24163 }
24164
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else if(get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC))
24165 {
24166 playLevelMusic();
24167 }
24168
24169 1 loadside=dir^1;
24170 1 }
24171
24172 264 bool HeroClass::nextcombo_wf(int32_t d2)
24173 {
24174
5/8
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 263 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 263 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
264 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
24175 264 return false;
24176
24177 // assumes Hero is about to scroll screens
24178
24179 int32_t ns = nextscr(d2);
24180
24181 if(ns==0xFFFF)
24182 return false;
24183
24184 // want actual screen index, not game->maps[] index
24185 ns = (ns&127) + (ns>>7)*MAPSCRS;
24186
24187 int32_t cx = x;
24188 int32_t cy = y;
24189
24190 switch(d2)
24191 {
24192 case up:
24193 cy=160;
24194 break;
24195
24196 case down:
24197 cy=0;
24198 break;
24199
24200 case left:
24201 cx=240;
24202 break;
24203
24204 case right:
24205 cx=0;
24206 break;
24207 }
24208
24209 // check lower half of combo
24210 cy += 8;
24211
24212 // from MAPCOMBO()
24213 int32_t cmb = (cy&0xF0)+(cx>>4);
24214
24215 if(cmb>175)
24216 return true;
24217
24218 newcombo c = combobuf[TheMaps[ns].data[cmb]];
24219 bool dried = iswater_type(c.type) && DRIEDLAKE;
24220 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24221 int32_t b=1;
24222
24223 if(cx&8) b<<=2;
24224
24225 if(cy&8) b<<=1;
24226
24227 if((c.walk&b) && !dried && !swim)
24228 return true;
24229
24230 // next block (i.e. cnt==2)
24231 if(!(cx&8))
24232 {
24233 b<<=2;
24234 }
24235 else
24236 {
24237 c = combobuf[TheMaps[ns].data[++cmb]];
24238 dried = iswater_type(c.type) && DRIEDLAKE;
24239 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24240 b=1;
24241
24242 if(cy&8)
24243 {
24244 b<<=1;
24245 }
24246 }
24247
24248 return (c.walk&b) ? !dried && !swim : false;
24249 264 }
24250
24251 bool HeroClass::nextcombo_solid(int32_t d2)
24252 {
24253 if(toogam || currscr>=128)
24254 return false;
24255
24256 // assumes Hero is about to scroll screens
24257
24258 int32_t ns = nextscr(d2);
24259
24260 if(ns==0xFFFF)
24261 return false;
24262
24263 // want actual screen index, not game->maps[] index
24264 ns = (ns&127) + (ns>>7)*MAPSCRS;
24265 int32_t screen = (ns%MAPSCRS);
24266 int32_t map = (ns - screen) / MAPSCRS;
24267
24268 int32_t cx = x;
24269 int32_t cy = y;
24270
24271 switch(d2)
24272 {
24273 case up:
24274 cy=160;
24275 break;
24276
24277 case down:
24278 cy=0;
24279 break;
24280
24281 case left:
24282 cx=240;
24283 break;
24284
24285 case right:
24286 cx=0;
24287 break;
24288 }
24289
24290 if(d2==up) cy += 8;
24291
24292 if(d2==left||d2==right) cy+=bigHitbox?0:8;
24293
24294 int32_t initcx = cx;
24295 int32_t initcy = cy;
24296 // from MAPCOMBO()
24297
24298 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
24299 {
24300 cx = initcx;
24301 for(int32_t k=0; k<=(get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
24302 {
24303 int32_t cmb = (cy&0xF0)+(cx>>4);
24304
24305 if(cmb>175)
24306 {
24307 return true;
24308 }
24309
24310 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))];
24311
24312 int32_t b=1;
24313
24314 if(cx&8) b<<=2;
24315
24316 if(cy&8) b<<=1;
24317
24318 //bool bridgedetected = false;
24319
24320 int32_t walk = c.walk;
24321 if (get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))
24322 {
24323 for (int32_t m = 0; m <= 1; m++)
24324 {
24325 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
24326 if (cmb.type == cBRIDGE)
24327 {
24328 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
24329 {
24330 int efflag = (cmb.walk & 0xF0)>>4;
24331 int newsolid = (cmb.walk & 0xF);
24332 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
24333 }
24334 else walk &= cmb.walk;
24335 }
24336 else walk |= cmb.walk;
24337 }
24338 }
24339 /*
24340 if (bridgedetected)
24341 {
24342 continue;
24343 }*/
24344
24345 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
24346 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
24347
24348 if((walk&b) && !swim)
24349 {
24350 return true;
24351 }
24352 }
24353
24354 /*
24355 #if 0
24356
24357 //
24358 // next block (i.e. cnt==2)
24359 if(!(cx&8))
24360 {
24361 b<<=2;
24362 }
24363 else
24364 {
24365 c = combobuf[TheMaps[ns].data[++cmb]];
24366 dried = iswater_type(c.type) && DRIEDLAKE;
24367 //swim = iswater_type(c.type) && (current_item(itype_flippers));
24368 b=1;
24369
24370 if(cy&8)
24371 {
24372 b<<=1;
24373 }
24374 }
24375
24376 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24377
24378 if((c.walk&b) && !dried && !swim)
24379 {
24380 return true;
24381 }
24382
24383 cx+=8;
24384
24385 if(cx&7)
24386 {
24387 if(!(cx&8))
24388 {
24389 b<<=2;
24390 }
24391 else
24392 {
24393 c = combobuf[TheMaps[ns].data[++cmb]];
24394 dried = iswater_type(c.type) && DRIEDLAKE;
24395 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24396 b=1;
24397
24398 if(cy&8)
24399 {
24400 b<<=1;
24401 }
24402 }
24403
24404 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24405
24406 if((c.walk&b) && !dried && !swim)
24407 return true;
24408 }
24409
24410 #endif
24411 */
24412 }
24413
24414 return false;
24415 }
24416
24417 79964 void HeroClass::checkscroll()
24418 {
24419 //DO NOT scroll if Hero is vibrating due to Farore's Wind effect -DD
24420
2/4
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79964 times.
✗ Branch 3 not taken.
79964 if(action == casting||action==sideswimcasting)
24421 return;
24422
24423
1/2
✓ Branch 0 taken 79964 times.
✗ Branch 1 not taken.
79964 if(toogam)
24424 {
24425 if(x<0 && (currscr&15)==0) x=0;
24426
24427 if(y<0 && currscr<16) y=0;
24428
24429 if(x>240 && (currscr&15)==15) x=240;
24430
24431 if(y>160 && currscr>=112) y=160;
24432 }
24433
24434
2/2
✓ Branch 0 taken 79848 times.
✓ Branch 1 taken 116 times.
79964 if(y<0)
24435 {
24436 116 bool doit=true;
24437 116 y=0;
24438
24439
4/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 108 times.
116 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24440 doit = false;
24441
24442
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(nextcombo_wf(up))
24443 doit=false;
24444
24445
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
108 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
24446 {
24447 if(nextcombo_solid(up))
24448 doit=false;
24449 }
24450
24451
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
108 if(doit || action==inwind)
24452 {
24453
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 107 times.
109 if(currscr>=128)
24454 {
24455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(specialcave >= GUYCAVE)
24456 exitcave();
24457 2 else stepout();
24458 2 }
24459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 else if(action==inwind)
24460 {
24461 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24462 {
24463 action=none; FFCore.setHeroAction(none);
24464 restart_level();
24465 }
24466 else
24467 {
24468 dowarp(2,up);
24469 }
24470 }
24471
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 95 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
107 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24472 {
24473 12 sdir=up;
24474 12 dowarp(1,(tmpscr->sidewarpindex)&3);
24475 12 }
24476
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 35 times.
95 else if(!edge_of_dmap(up))
24477 {
24478 35 scrolling_map = currmap;
24479 35 scrollscr(up);
24480
24481
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tmpscr->flags4&fAUTOSAVE)
24482 {
24483 save_game(true,0);
24484 }
24485
24486
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tmpscr->flags6&fCONTINUEHERE)
24487 {
24488 lastentrance_dmap = currdmap;
24489 lastentrance = homescr;
24490 }
24491 35 }
24492 109 }
24493 110 }
24494
24495
2/2
✓ Branch 0 taken 79937 times.
✓ Branch 1 taken 19 times.
79956 if(y>160)
24496 {
24497 19 bool doit=true;
24498 19 y=160;
24499
24500
3/6
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 19 times.
19 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24501 doit = false;
24502
24503
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(nextcombo_wf(down))
24504 doit=false;
24505
24506
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
19 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
24507 {
24508 if(nextcombo_solid(down))
24509 doit=false;
24510 }
24511
24512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19 if(doit || action==inwind)
24513 {
24514
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 9 times.
19 if(currscr>=128)
24515 {
24516
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(specialcave >= GUYCAVE)
24517 10 exitcave();
24518 else stepout();
24519 10 }
24520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(action==inwind)
24521 {
24522 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24523 {
24524 action=none; FFCore.setHeroAction(none);
24525 restart_level();
24526 }
24527 else
24528 {
24529 dowarp(2,down);
24530 }
24531 }
24532
3/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24533 {
24534 1 sdir=down;
24535 1 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
24536 1 }
24537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if(!edge_of_dmap(down))
24538 {
24539 8 scrolling_map = currmap;
24540 8 scrollscr(down);
24541
24542
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(tmpscr->flags4&fAUTOSAVE)
24543 {
24544 save_game(true,0);
24545 }
24546
24547
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(tmpscr->flags6&fCONTINUEHERE)
24548 {
24549 lastentrance_dmap = currdmap;
24550 lastentrance = homescr;
24551 }
24552 8 }
24553 19 }
24554 19 }
24555
24556
2/2
✓ Branch 0 taken 79924 times.
✓ Branch 1 taken 32 times.
79956 if(x<0)
24557 {
24558 32 bool doit=true;
24559 32 x=0;
24560
24561
3/6
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
32 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24562 doit = false;
24563
24564
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(nextcombo_wf(left))
24565 doit=false;
24566
24567
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
32 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
24568 {
24569 if(nextcombo_solid(left))
24570 doit=false;
24571 }
24572
24573
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
32 if(doit || action==inwind)
24574 {
24575
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(currscr>=128)
24576 {
24577 if(specialcave >= GUYCAVE)
24578 exitcave();
24579 else stepout();
24580 }
24581
24582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(action==inwind)
24583 {
24584 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24585 {
24586 action=none; FFCore.setHeroAction(none);
24587 restart_level();
24588 }
24589 else
24590 {
24591 dowarp(2,left);
24592 }
24593 }
24594
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
32 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24595 {
24596 sdir=left;
24597 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
24598 }
24599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 else if(!edge_of_dmap(left))
24600 {
24601 32 scrolling_map = currmap;
24602 32 scrollscr(left);
24603
24604
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(tmpscr->flags4&fAUTOSAVE)
24605 {
24606 save_game(true,0);
24607 }
24608
24609
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(tmpscr->flags6&fCONTINUEHERE)
24610 {
24611 lastentrance_dmap = currdmap;
24612 lastentrance = homescr;
24613 }
24614 32 }
24615 32 }
24616 32 }
24617
24618
2/2
✓ Branch 0 taken 79888 times.
✓ Branch 1 taken 68 times.
79956 if(x>240)
24619 {
24620 68 bool doit=true;
24621 68 x=240;
24622
24623
4/6
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 66 times.
68 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24624 doit = false;
24625
24626
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(nextcombo_wf(right))
24627 doit=false;
24628
24629
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
66 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
24630 {
24631 if(nextcombo_solid(right))
24632 doit=false;
24633 }
24634
24635
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(doit || action==inwind)
24636 {
24637
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(currscr>=128)
24638 {
24639 if(specialcave >= GUYCAVE)
24640 exitcave();
24641 else stepout();
24642 }
24643
24644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(action==inwind)
24645 {
24646 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24647 {
24648 action=none; FFCore.setHeroAction(none);
24649 restart_level();
24650 }
24651 else
24652 {
24653 dowarp(2,right);
24654 }
24655 }
24656
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
66 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24657 {
24658 25 sdir=right;
24659 25 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
24660 25 }
24661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 else if(!edge_of_dmap(right))
24662 {
24663 41 scrolling_map = currmap;
24664 41 scrollscr(right);
24665
24666
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(tmpscr->flags4&fAUTOSAVE)
24667 {
24668 save_game(true,0);
24669 }
24670
24671
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(tmpscr->flags6&fCONTINUEHERE)
24672 {
24673 lastentrance_dmap = currdmap;
24674 lastentrance = homescr;
24675 }
24676 41 }
24677 66 }
24678 66 }
24679 79954 }
24680
24681 // assumes current direction is in lastdir[3]
24682 // compares directions with scr->path and scr->exitdir
24683 420 bool HeroClass::checkmaze(mapscr *scr, bool sound)
24684 {
24685
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if(!(scr->flags&fMAZE))
24686 420 return true;
24687
24688 if(lastdir[3]==scr->exitdir)
24689 return true;
24690
24691 for(int32_t i=0; i<4; i++)
24692 if(lastdir[i]!=scr->path[i])
24693 return false;
24694
24695 if(sound)
24696 sfx(scr->secretsfx);
24697
24698 return true;
24699 420 }
24700
24701 300 bool HeroClass::edge_of_dmap(int32_t side)
24702 {
24703
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(checkmaze(tmpscr,false)==false)
24704 return false;
24705
24706 // needs fixin'
24707 // should check dmap style
24708
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 64 times.
✓ Branch 4 taken 84 times.
300 switch(side)
24709 {
24710 case up:
24711 136 return currscr<16;
24712
24713 case down:
24714 16 return currscr>=112;
24715
24716 case left:
24717
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if((currscr&15)==0)
24718 return true;
24719
24720
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 28 times.
64 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24721 // if(dlevel)
24722 36 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
24723
24724 28 break;
24725
24726 case right:
24727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if((currscr&15)==15)
24728 return true;
24729
24730
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 32 times.
84 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24731 // if(dlevel)
24732 52 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
24733
24734 32 break;
24735 }
24736
24737 60 return false;
24738 300 }
24739
24740 bool HeroClass::lookaheadraftflag(int32_t d2)
24741 {
24742 // Helper for scrollscr that gets next combo on next screen.
24743 // Can use destscr for scrolling warps,
24744 // but assumes currmap is correct.
24745
24746 int32_t cx = x;
24747 int32_t cy = y + 8;
24748
24749 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24750 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24751 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24752 //Applying this here, too. -Z
24753
24754 switch(d2)
24755 {
24756 case up:
24757 cy=160;
24758 break;
24759
24760 case down:
24761 cy=0;
24762 break;
24763
24764 case left:
24765 cx=240;
24766 break;
24767
24768 case right:
24769 cx=0;
24770 break;
24771 }
24772
24773 int32_t combo = (cy&0xF0)+(cx>>4);
24774
24775 if(combo>175)
24776 return 0;
24777 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
24778
24779 }
24780 116 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
24781 {
24782 // Can use destscr for scrolling warps,
24783 // but assumes currmap is correct.
24784
24785 116 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
24786 116 int32_t cy = vbound(y + 8,0,160);
24787 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24788 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24789 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24790
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 41 times.
116 switch(d2)
24791 {
24792 case up:
24793 35 cy=160;
24794 35 break;
24795
24796 case down:
24797 8 cy=0;
24798 8 break;
24799
24800 case left:
24801 32 cx=240;
24802 32 break;
24803
24804 case right:
24805 41 cx=0;
24806 41 break;
24807 }
24808
24809 116 int32_t combo = (cy&0xF0)+(cx>>4);
24810
24811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(combo>175)
24812 return 0;
24813
24814 116 return tmpscr[0].data[combo]; // entire combo code
24815 116 }
24816
24817 116 int32_t HeroClass::lookaheadflag(int32_t d2)
24818 {
24819 // Helper for scrollscr that gets next combo on next screen.
24820 // Can use destscr for scrolling warps,
24821 // but assumes currmap is correct.
24822
24823 116 int32_t cx = vbound(x,0,240);
24824 116 int32_t cy = vbound(y + 8,0,160);
24825
24826 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24827 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24828 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24829 //Applying this here, too. -Z
24830
24831
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 41 times.
116 switch(d2)
24832 {
24833 case up:
24834 35 cy=160;
24835 35 break;
24836
24837 case down:
24838 8 cy=0;
24839 8 break;
24840
24841 case left:
24842 32 cx=240;
24843 32 break;
24844
24845 case right:
24846 41 cx=0;
24847 41 break;
24848 }
24849
24850 116 int32_t combo = (cy&0xF0)+(cx>>4);
24851
24852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(combo>175)
24853 return 0;
24854
24855
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!tmpscr[0].sflag[combo])
24856 {
24857 116 return combobuf[tmpscr[0].data[combo]].flag; // flag
24858 }
24859
24860 return tmpscr[0].sflag[combo]; // flag
24861 116 }
24862
24863 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
24864 20817 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
24865 {
24866 // For rafting (and possibly other esoteric things)
24867 // Hero's action should remain unchanged while scrolling,
24868 // but for the sake of scripts, here's an eye-watering kludge.
24869 20817 actiontype lastaction = action;
24870 20817 action=scrolling; FFCore.setHeroAction(scrolling);
24871
2/2
✓ Branch 0 taken 10401 times.
✓ Branch 1 taken 10416 times.
20817 if(waitdraw)
24872 {
24873 10401 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
24874 10401 }
24875 else
24876 {
24877 10416 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
24878 }
24879 20817 zfix storex = x, storey = y;
24880
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4817 times.
✓ Branch 2 taken 1178 times.
✓ Branch 3 taken 6189 times.
✓ Branch 4 taken 8633 times.
20817 switch(scrolldir)
24881 {
24882 case up:
24883
2/2
✓ Branch 0 taken 4141 times.
✓ Branch 1 taken 676 times.
4817 if(y < 160) y = 176;
24884
4/4
✓ Branch 0 taken 581 times.
✓ Branch 1 taken 95 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 413 times.
676 else if(cx > 0 && !end_frames) y = sy + 156;
24885 263 else y = 160;
24886
24887 4817 break;
24888
24889 case down:
24890
2/2
✓ Branch 0 taken 990 times.
✓ Branch 1 taken 188 times.
1178 if(y > 0) y = -16;
24891
4/4
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 106 times.
188 else if(cx > 0 && !end_frames) y = sy - 172;
24892 82 else y = 0;
24893
24894 1178 break;
24895
24896 case left:
24897
2/2
✓ Branch 0 taken 5710 times.
✓ Branch 1 taken 479 times.
6189 if(x < 240) x = 256;
24898
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 69 times.
479 else if(cx > 0) x = sx + 236;
24899 69 else x = 240;
24900
24901 6189 break;
24902
24903 case right:
24904
2/2
✓ Branch 0 taken 7975 times.
✓ Branch 1 taken 658 times.
8633 if(x > 0) x = -16;
24905
2/2
✓ Branch 0 taken 569 times.
✓ Branch 1 taken 89 times.
658 else if(cx > 0) x = sx - 252;
24906 89 else x = 0;
24907
24908 8633 break;
24909 }
24910
2/2
✓ Branch 0 taken 10401 times.
✓ Branch 1 taken 10416 times.
20817 if(waitdraw)
24911 {
24912
3/4
✓ Branch 0 taken 10401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10300 times.
✓ Branch 3 taken 101 times.
10401 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
24913 {
24914 101 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24915 101 global_wait&= ~(1<<GLOBAL_SCRIPT_GAME);
24916 101 }
24917 10401 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
24918
2/6
✓ Branch 0 taken 10401 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10401 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10401 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24919 {
24920 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24921 player_waitdraw = false;
24922 }
24923 10401 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
24924
2/6
✓ Branch 0 taken 10401 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10401 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10401 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24925 {
24926 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24927 dmap_waitdraw = false;
24928 }
24929 10401 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
24930
2/6
✓ Branch 0 taken 10401 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10401 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10401 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24931 {
24932 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24933 passive_subscreen_waitdraw = false;
24934 }
24935 10401 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
24936
2/10
✓ Branch 0 taken 10401 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10401 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
10401 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24937 {
24938 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24939 tmpscr->screen_waitdraw = 0;
24940 }
24941 10401 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
24942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10401 times.
10401 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
24943 {
24944 10401 FFCore.itemScriptEngineOnWaitdraw();
24945 10401 }
24946 10401 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
24947 10401 }
24948 else
24949 {
24950
2/8
✓ Branch 0 taken 10416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10416 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24951 {
24952 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24953 }
24954 10416 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
24955
3/4
✓ Branch 0 taken 10416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9461 times.
✓ Branch 3 taken 955 times.
10416 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (g_doscript & (1<<GLOBAL_SCRIPT_GAME)))
24956 {
24957 955 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24958 955 }
24959 10416 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
24960
4/6
✓ Branch 0 taken 10416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9527 times.
✓ Branch 3 taken 889 times.
✓ Branch 4 taken 9527 times.
✗ Branch 5 not taken.
10416 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && player_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
24961 {
24962 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24963 }
24964 10416 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
24965
4/6
✓ Branch 0 taken 10416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9527 times.
✓ Branch 5 taken 889 times.
10416 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24966 {
24967 889 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24968 889 }
24969 10416 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
24970
4/6
✓ Branch 0 taken 10416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9527 times.
✓ Branch 5 taken 889 times.
10416 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24971 {
24972 889 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24973 889 }
24974 10416 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
24975 10416 bool old = get_bit(quest_rules, qr_OLD_ITEMDATA_SCRIPT_TIMING);
24976
3/4
✓ Branch 0 taken 10416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 889 times.
✓ Branch 3 taken 9527 times.
10416 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
24977 9527 FFCore.itemScriptEngine();
24978 10416 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
24979
3/4
✓ Branch 0 taken 10416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9527 times.
✓ Branch 3 taken 889 times.
10416 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
24980 889 FFCore.itemScriptEngine();
24981 }
24982
24983 20817 x = storex, y = storey;
24984
24985 20817 action=lastaction; FFCore.setHeroAction(lastaction);
24986 20817 }
24987
24988 //Has solving the maze enabled a side warp?
24989 //Only used just before scrolling screens
24990 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
24991 // return true to abort the topmost scrollscr() call. -L
24992 120 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
24993 {
24994
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 120 times.
480 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
24995
24996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
24997
24998
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
24999 {
25000 switch(scrolldir)
25001 {
25002 case up:
25003 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
25004 {
25005 lastdir[3] = 0xFF;
25006 sdir=up;
25007 dowarp(1,(tmpscr->sidewarpindex)&3);
25008 return true;
25009 }
25010
25011 break;
25012
25013 case down:
25014 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
25015 {
25016 lastdir[3] = 0xFF;
25017 sdir=down;
25018 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
25019 return true;
25020 }
25021
25022 break;
25023
25024 case left:
25025 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
25026 {
25027 lastdir[3] = 0xFF;
25028 sdir=left;
25029 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
25030 return true;
25031 }
25032
25033 break;
25034
25035 case right:
25036 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
25037 {
25038 lastdir[3] = 0xFF;
25039 sdir=right;
25040 dowarp(1,(tmpscr->sidewarpindex)&3);
25041 return true;
25042 }
25043
25044 break;
25045 }
25046 }
25047
25048 120 return false;
25049 120 }
25050
25051 120 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
25052 {
25053 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
25054
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 118 times.
120 if(get_bit(quest_rules, qr_VERYFASTSCROLLING))
25055 2 return 16;
25056
25057
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 34 times.
118 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0)
25058 {
25059
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 49 times.
84 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25060 }
25061 else
25062 {
25063
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
34 if(scrolldir == up || scrolldir == down)
25064 {
25065 12 return 8;
25066 }
25067 else
25068 {
25069
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9 times.
22 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25070 }
25071 }
25072 120 }
25073
25074 120 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
25075 {
25076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(get_bit(quest_rules, qr_NOSCROLL))
25077 return 0;
25078
25079
4/4
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 34 times.
120 if( (get_bit(quest_rules, qr_VERYFASTSCROLLING) != 0) ||
25080 118 (get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0) )
25081 {
25082 86 return 1;
25083 }
25084 else
25085 {
25086
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
34 if(scrolldir == up || scrolldir == down)
25087 {
25088
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8 times.
12 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 4 : 2;
25089 }
25090 else
25091 {
25092 22 return 1;
25093 }
25094 }
25095 120 }
25096
25097 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
25098 {
25099 int32_t itemid = current_item_id(itype_lantern);
25100 if(itemid < 0) return; //no lantern light circle
25101 int32_t hx1 = x.getInt() - x1 + 8;
25102 int32_t hy1 = y.getInt() - y1 + 8;
25103 int32_t hx2 = x.getInt() - x2 + 8;
25104 int32_t hy2 = y.getInt() - y2 + 8;
25105
25106 itemdata& lamp = itemsbuf[itemid];
25107 switch(lamp.misc1) //Shape
25108 {
25109 case 0: //Circle
25110 doDarkroomCircle(hx1, hy1, lamp.misc2, darkscr_bmp_curscr);
25111 doDarkroomCircle(hx2, hy2, lamp.misc2, darkscr_bmp_scrollscr);
25112 break;
25113 case 1: //Lamp Cone
25114 doDarkroomCone(hx1, hy1, lamp.misc2, dir, darkscr_bmp_curscr);
25115 doDarkroomCone(hx2, hy2, lamp.misc2, dir, darkscr_bmp_scrollscr);
25116 break;
25117 }
25118 }
25119
25120 124 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
25121 {
25122
4/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 124 times.
124 if(action==freeze||action==sideswimfreeze)
25123 {
25124 8 return;
25125 }
25126
25127 124 bool overlay = false;
25128
25129
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
124 if(scrolldir >= 0 && scrolldir <= 3)
25130 {
25131 120 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
25132 120 }
25133
25134
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 120 times.
124 if(destdmap == -1)
25135 {
25136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
25137
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
25138 return;
25139 120 }
25140 else
25141 {
25142
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
4 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
25143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
25144 8 return;
25145 }
25146
25147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
25148 return;
25149
25150 124 kill_enemy_sfx();
25151 124 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25152 124 screenscrolling = true;
25153 124 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
25154
5/5
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 42 times.
124 switch(scrolldir)
25155 {
25156 case up:
25157 38 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25158 38 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
25159 38 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25160 38 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25161 38 break;
25162 case down:
25163 8 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25164 8 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
25165 8 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25166 8 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25167 8 break;
25168 case left:
25169 32 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
25170 32 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25171 32 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25172 32 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25173 32 break;
25174 case right:
25175 42 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
25176 42 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25177 42 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25178 42 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25179 42 break;
25180 }
25181 124 FFCore.init_combo_doscript();
25182 124 tmpscr[1] = tmpscr[0];
25183
25184 124 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
25185
25186
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 124 times.
844 for(int32_t i = 0; i < 6; i++)
25187 {
25188 720 tmpscr3[i] = tmpscr2[i];
25189 720 }
25190
25191 124 conveyclk = 2;
25192
25193 124 mapscr *newscr = &tmpscr[0];
25194 124 mapscr *oldscr = &tmpscr[1];
25195
25196 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
25197 124 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
25198 124 int32_t cx = 0;
25199 124 int32_t step = get_scroll_step(scrolldir);
25200 124 int32_t delay = get_scroll_delay(scrolldir);
25201 124 bool end_frames = false;
25202
25203 124 int32_t scx = get_bit(quest_rules,qr_FASTDNGN) ? 30 : 0;
25204
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 2 times.
124 if(get_bit(quest_rules, qr_VERYFASTSCROLLING)) //just a minor adjustment.
25205 2 scx = 32; //for sideview very fast screolling.
25206
25207
25208 124 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
25209 124 actiontype lastaction = action;
25210 124 ALLOFF(false, false);
25211 // for now, restore Hero's previous action
25212
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 15 times.
124 if(!get_bit(quest_rules, qr_SCROLLING_KILLS_CHARGE))
25213 124 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
25214 124 action=lastaction; FFCore.setHeroAction(lastaction);
25215
25216 124 lstep = (lstep + 6) % 12;
25217 124 cx = scx;
25218 124 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
25219
4/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 116 times.
✓ Branch 3 taken 4 times.
124 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
25220 {
25221 4 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
25222 4 global_wait &= ~(1<<GLOBAL_SCRIPT_GAME);
25223 4 }
25224 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
25225
3/6
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
124 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25226 {
25227 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
25228 player_waitdraw = false;
25229 }
25230 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
25231
3/6
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
124 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25232 {
25233 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
25234 dmap_waitdraw = false;
25235 }
25236 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
25237
3/6
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
124 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25238 {
25239 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
25240 passive_subscreen_waitdraw = false;
25241 }
25242 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
25243
3/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
124 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25244 {
25245 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
25246 tmpscr->screen_waitdraw = 0;
25247 }
25248 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
25249
25250 124 word c = tmpscr->numFFC();
25251
2/2
✓ Branch 0 taken 3611 times.
✓ Branch 1 taken 124 times.
3735 for ( word q = 0; q < c; ++q )
25252 {
25253 //Z_scripterrlog("tmpscr->ffcswaitdraw is: %d\n", tmpscr->ffcswaitdraw);
25254
1/2
✓ Branch 0 taken 3611 times.
✗ Branch 1 not taken.
3611 if ( tmpscr->ffcswaitdraw&(1<<q) )
25255 {
25256 //Z_scripterrlog("FFC (%d) called Waitdraw()\n", q);
25257 if(tmpscr->ffcs[q].script != 0)
25258 {
25259 ZScriptVersion::RunScript(SCRIPT_FFC, tmpscr->ffcs[q].script, q);
25260 tmpscr->ffcswaitdraw &= ~(1<<q);
25261 }
25262 }
25263 3611 }
25264 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
25265 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
25266 //Waitdraw for item scripts.
25267 124 FFCore.itemScriptEngineOnWaitdraw();
25268 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
25269 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
25270
25271 //Sprite scripts on Waitdraw
25272 124 FFCore.eweaponScriptEngineOnWaitdraw();
25273 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
25274 124 FFCore.itemSpriteScriptEngineOnWaitdraw();
25275 124 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
25276
25277 //This is no longer a do-while, as the first iteration is now slightly different. -Em
25278 124 draw_screen(tmpscr,true,true);
25279
25280
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 120 times.
124 if(cx == scx)
25281 120 rehydratelake(false);
25282
25283 124 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25284 124 advanceframe(true);
25285
25286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(Quit)
25287 {
25288 screenscrolling = false;
25289 return;
25290 }
25291
25292 124 ++cx;
25293
2/2
✓ Branch 0 taken 3058 times.
✓ Branch 1 taken 124 times.
3182 while(cx < 32)
25294 {
25295
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3045 times.
3058 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
25296 {
25297 13 script_drawing_commands.Clear();
25298 13 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25299 13 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
25300 13 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25301 13 }
25302 3045 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25303 3058 draw_screen(tmpscr,true,true);
25304
25305
1/2
✓ Branch 0 taken 3058 times.
✗ Branch 1 not taken.
3058 if(cx == scx)
25306 rehydratelake(false);
25307
25308 3058 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25309 3058 advanceframe(true);
25310
25311
1/2
✓ Branch 0 taken 3058 times.
✗ Branch 1 not taken.
3058 if(Quit)
25312 {
25313 screenscrolling = false;
25314 return;
25315 }
25316
25317 3058 ++cx;
25318 }
25319 124 script_drawing_commands.Clear();
25320 124 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25321
25322
25323 //clear Hero's last hits
25324 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
25325
25326
4/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 66 times.
124 switch(DMaps[currdmap].type&dmfTYPE)
25327 {
25328 case dmDNGN:
25329
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!get_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING))
25330 {
25331 markBmap(scrolldir);
25332 }
25333 66 break;
25334 case dmOVERW: case dmBSOVERW:
25335
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 39 times.
52 if(get_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING))
25336 39 break;
25337 [[fallthrough]];
25338 case dmCAVE:
25339 15 markBmap(scrolldir);
25340 15 break;
25341 }
25342
25343
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(fixed_door)
25344 {
25345 unsetmapflag(mSECRET);
25346 fixed_door = false;
25347 }
25348 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
25349 124 scrolling_scr = currscr;
25350
25351
5/5
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 42 times.
124 switch(scrolldir)
25352 {
25353 case up:
25354 {
25355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(destscr != -1)
25356 currscr = destscr;
25357
2/4
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
38 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25358 38 currscr -= 16;
25359
25360 38 loadscr(0,destdmap,currscr,scrolldir,overlay);
25361 38 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
25362 38 putscr(scrollbuf,0,0,newscr);
25363 38 putscrdoors(scrollbuf,0,0,newscr);
25364 38 sy=176;
25365
25366
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 11 times.
38 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25367 11 sy+=3;
25368
25369 38 cx=176/step;
25370 38 FFCore.init_combo_doscript();
25371 }
25372 38 break;
25373
25374 case down:
25375 {
25376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(destscr != -1)
25377 currscr = destscr;
25378
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25379 8 currscr += 16;
25380
25381 8 loadscr(0,destdmap,currscr,scrolldir,overlay);
25382 8 putscr(scrollbuf,0,176,newscr);
25383 8 putscrdoors(scrollbuf,0,176,newscr);
25384 8 sy = 0;
25385
25386
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25387 sy+=3;
25388
25389 8 cx = 176 / step;
25390 8 FFCore.init_combo_doscript();
25391 }
25392 8 break;
25393
25394 case left:
25395 {
25396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(destscr!=-1)
25397 currscr = destscr;
25398
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
32 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25399 32 --currscr;
25400
25401 32 loadscr(0,destdmap,currscr,scrolldir,overlay);
25402 32 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
25403 32 putscr(scrollbuf,0,0,newscr);
25404 32 putscrdoors(scrollbuf,0,0,newscr);
25405 32 sx = 256;
25406 32 cx = 256 / step;
25407 32 FFCore.init_combo_doscript();
25408 }
25409 32 break;
25410
25411 case right:
25412 {
25413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(destscr != -1)
25414 currscr = destscr;
25415
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25416 42 ++currscr;
25417
25418 42 loadscr(0,destdmap,currscr,scrolldir,overlay);
25419 42 putscr(scrollbuf,256,0,newscr);
25420 42 putscrdoors(scrollbuf,256,0,tmpscr);
25421 42 sx = 0;
25422 42 cx = 256 / step;
25423 42 FFCore.init_combo_doscript();
25424 }
25425 42 break;
25426 }
25427
25428 // change Hero's state if entering water
25429 124 int32_t ahead = lookahead(scrolldir);
25430 124 int32_t aheadflag = lookaheadflag(scrolldir);
25431 124 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
25432 124 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
25433 124 int32_t wateraheadx1 = vbound(x+4,0,240);
25434 124 int32_t wateraheadx2 = vbound(x+11,0,240);;
25435 124 int32_t wateraheady1 = vbound(y+9,0,160);
25436 124 int32_t wateraheady2 = vbound(y+15,0,160);
25437 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25438 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25439 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
25440
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 41 times.
124 switch(scrolldir)
25441 {
25442 case up:
25443 35 lookaheady=160;
25444 35 wateraheady1=160;
25445 35 wateraheady2=160;
25446 35 break;
25447
25448 case down:
25449 8 lookaheady=0;
25450 8 wateraheady1=0;
25451 8 wateraheady2=0;
25452 8 break;
25453
25454 case left:
25455 32 lookaheadx=240;
25456 32 wateraheadx1=240;
25457 32 wateraheadx2=240;
25458 32 break;
25459
25460 case right:
25461 41 lookaheadx=0;
25462 41 wateraheadx1=0;
25463 41 wateraheadx2=0;
25464 41 break;
25465 }
25466
25467 116 bool nowinwater = false;
25468
25469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(lastaction != inwind)
25470 {
25471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
25472 {
25473 if (lookaheadraftflag(scrolldir))
25474 {
25475 action=rafting; FFCore.setHeroAction(rafting);
25476 raftclk=0;
25477 }
25478 }
25479
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
116 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
25480 {
25481
1/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
25482 {
25483 1 SetSwim();
25484 1 hopclk = 0xFF;
25485 1 nowinwater = true;
25486 1 }
25487 else
25488 {
25489 action=hopping; FFCore.setHeroAction(hopping);
25490 hopclk = 2;
25491 nowinwater = true;
25492 }
25493 1 }
25494
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
25495 {
25496 action = lastaction; FFCore.setHeroAction(lastaction);
25497 }
25498 else
25499 {
25500 115 action=none; FFCore.setHeroAction(none);
25501 }
25502 116 }
25503
25504 // The naturaldark state can be read/set by an FFC script before
25505 // fade() or lighting() is called.
25506 116 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
25507
25508
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
25509
25510
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 5 times.
116 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
25511 //Preloaded ffc scripts
25512 116 homescr=currscr;
25513 116 auto olddmap = currdmap;
25514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
25515
25516 116 currdmap = newdmap;
25517 116 ffscript_engine(true);
25518 116 currdmap = olddmap;
25519
25520 // There are two occasions when scrolling must be darkened:
25521 // 1) When scrolling into a dark room.
25522 // 2) When scrolling between DMaps of different colours.
25523
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116 if(destdmap != -1 && DMaps[destdmap].color != currcset)
25524 {
25525 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
25526 darkroom = true;
25527 }
25528
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 110 times.
116 else if(!darkroom)
25529 110 lighting(false, false); // NES behaviour: fade to dark before scrolling
25530
25531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(action != rafting) // Is this supposed to be here?!
25532
25533 116 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
25534
25535 116 cx *= delay; //so we can have drawing re-done every frame,
25536 //previously it was for(0 to delay) advanceframes at end of loop
25537 116 int32_t no_move = 0;
25538
25539 116 currdmap = newdmap;
25540
4/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 10388 times.
✓ Branch 2 taken 10388 times.
✓ Branch 3 taken 116 times.
10504 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
25541 {
25542
3/4
✓ Branch 0 taken 10388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5779 times.
✓ Branch 3 taken 4609 times.
10388 if (replay_is_active() && replay_get_version() < 3)
25543 {
25544 4609 replay_poll();
25545 4609 }
25546
1/2
✓ Branch 0 taken 10388 times.
✗ Branch 1 not taken.
10388 if(Quit)
25547 {
25548 screenscrolling = false;
25549 return;
25550 }
25551
25552
25553 10388 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
25554
25555
2/2
✓ Branch 0 taken 9674 times.
✓ Branch 1 taken 714 times.
10388 if(no_move > 0)
25556 714 no_move--;
25557
25558 //Don't want to move things on the first or last iteration, or between delays
25559
6/6
✓ Branch 0 taken 10272 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 10124 times.
✓ Branch 3 taken 148 times.
✓ Branch 4 taken 448 times.
✓ Branch 5 taken 9676 times.
10388 if(i == 0 || cx == 0 || cx % delay != 0)
25560 712 no_move++;
25561
25562
4/4
✓ Branch 0 taken 7981 times.
✓ Branch 1 taken 2407 times.
✓ Branch 2 taken 587 times.
✓ Branch 3 taken 7394 times.
10388 if(scrolldir == up || scrolldir == down)
25563 {
25564
2/2
✓ Branch 0 taken 2271 times.
✓ Branch 1 taken 723 times.
2994 if(!get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING))
25565 {
25566 //Add a few extra frames if on the second loop and cool scrolling is not set
25567
2/2
✓ Branch 0 taken 712 times.
✓ Branch 1 taken 11 times.
723 if(i == 1)
25568 {
25569 11 cx += (scrolldir == down) ? 3 : 2;
25570 11 no_move += (scrolldir == down) ? 3 : 2;
25571 11 }
25572 723 }
25573 else
25574 {
25575 //4 frames after we've finished scrolling of being still
25576
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 2207 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 32 times.
2271 if(cx == 0 && !end_frames)
25577 {
25578 32 cx += 4;
25579 32 no_move += 4;
25580 32 end_frames = true;
25581 32 }
25582 }
25583 2994 }
25584
25585 //Move Hero and the scroll position
25586
2/2
✓ Branch 0 taken 830 times.
✓ Branch 1 taken 9558 times.
10388 if(!no_move)
25587 {
25588
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1771 times.
✓ Branch 2 taken 539 times.
✓ Branch 3 taken 3024 times.
✓ Branch 4 taken 4224 times.
9558 switch(scrolldir)
25589 {
25590 case up:
25591 1771 sy -= step;
25592 1771 y += step;
25593 1771 break;
25594
25595 case down:
25596 539 sy += step;
25597 539 y -= step;
25598 539 break;
25599
25600 case left:
25601 3024 sx -= step;
25602 3024 x += step;
25603 3024 break;
25604
25605 case right:
25606 4224 sx += step;
25607 4224 x -= step;
25608 4224 break;
25609 }
25610
25611 //bound Hero when me move him off the screen in the last couple of frames of scrolling
25612
2/2
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 9407 times.
9558 if(y > 160) y = 160;
25613
25614
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 9509 times.
9558 if(y < 0) y = 0;
25615
25616
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 9369 times.
9558 if(x > 240) x = 240;
25617
25618
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 9294 times.
9558 if(x < 0) x = 0;
25619
25620
2/4
✓ Branch 0 taken 9558 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9558 times.
9558 if(ladderx > 0 || laddery > 0)
25621 {
25622 // If the ladder moves on both axes, the player can
25623 // gradually shift it by going back and forth
25624 if(scrolldir==up || scrolldir==down)
25625 laddery = y.getInt();
25626 else
25627 ladderx = x.getInt();
25628 }
25629 9558 }
25630
25631 //Drawing
25632 10388 tx = sx;
25633 10388 ty = sy;
25634 10388 tx2 = sx;
25635 10388 ty2 = sy;
25636
25637
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4306 times.
✓ Branch 2 taken 587 times.
✓ Branch 3 taken 3088 times.
✓ Branch 4 taken 2407 times.
10388 switch(scrolldir)
25638 {
25639 case right:
25640 4306 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
25641 4306 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25642 4306 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
25643 4306 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25644 4306 tx -= 256;
25645 4306 break;
25646
25647 case down:
25648 587 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25649 587 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
25650 587 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25651 587 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
25652 587 ty -= 176;
25653 587 break;
25654
25655 case left:
25656 3088 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
25657 3088 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25658 3088 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
25659 3088 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25660 3088 tx2 -= 256;
25661 3088 break;
25662
25663 case up:
25664 2407 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25665 2407 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
25666 2407 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25667 2407 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
25668 2407 ty2 -= 176;
25669 2407 break;
25670 }
25671
25672 //FFScript.OnWaitdraw()
25673 10388 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25674
25675 10388 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
25676 10388 clear_bitmap(scrollbuf);
25677 10388 clear_bitmap(framebuf);
25678
25679
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2407 times.
✓ Branch 2 taken 587 times.
✓ Branch 3 taken 3088 times.
✓ Branch 4 taken 4306 times.
10388 switch(scrolldir)
25680 {
25681 case up:
25682
1/2
✓ Branch 0 taken 2407 times.
✗ Branch 1 not taken.
2407 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25683
25684
1/2
✓ Branch 0 taken 2407 times.
✗ Branch 1 not taken.
2407 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
25685
25686
1/2
✓ Branch 0 taken 2407 times.
✗ Branch 1 not taken.
2407 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25687
25688
1/2
✓ Branch 0 taken 2407 times.
✗ Branch 1 not taken.
2407 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
25689
25690 // Draw both screens' background layer primitives together, after both layers' combos.
25691 // Not ideal, but probably good enough for all realistic purposes.
25692
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2407 times.
✓ Branch 2 taken 2407 times.
✗ Branch 3 not taken.
2407 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25693
25694
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2407 times.
✓ Branch 2 taken 2407 times.
✗ Branch 3 not taken.
2407 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25695
25696 2407 putscr(scrollbuf, 0, 0, newscr);
25697 2407 putscr(scrollbuf, 0, 176, oldscr);
25698 2407 break;
25699
25700 case down:
25701
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
25702
25703
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25704
25705
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
25706
25707
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25708
25709
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 587 times.
✓ Branch 2 taken 587 times.
✗ Branch 3 not taken.
587 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25710
25711
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 587 times.
✓ Branch 2 taken 587 times.
✗ Branch 3 not taken.
587 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25712
25713 587 putscr(scrollbuf, 0, 0, oldscr);
25714 587 putscr(scrollbuf, 0, 176, newscr);
25715 587 break;
25716
25717 case left:
25718
2/2
✓ Branch 0 taken 3022 times.
✓ Branch 1 taken 66 times.
3088 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25719
25720
1/2
✓ Branch 0 taken 3088 times.
✗ Branch 1 not taken.
3088 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
25721
25722
1/2
✓ Branch 0 taken 3088 times.
✗ Branch 1 not taken.
3088 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25723
25724
1/2
✓ Branch 0 taken 3088 times.
✗ Branch 1 not taken.
3088 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
25725
25726
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 3022 times.
✓ Branch 2 taken 3022 times.
✓ Branch 3 taken 66 times.
3088 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25727
25728
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3088 times.
✓ Branch 2 taken 3088 times.
✗ Branch 3 not taken.
3088 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25729
25730 3088 putscr(scrollbuf, 0, 0, newscr);
25731 3088 putscr(scrollbuf, 256, 0, oldscr);
25732 3088 break;
25733
25734 case right:
25735
2/2
✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 66 times.
4306 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
25736
25737
2/2
✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 66 times.
4306 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25738
25739
1/2
✓ Branch 0 taken 4306 times.
✗ Branch 1 not taken.
4306 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
25740
25741
1/2
✓ Branch 0 taken 4306 times.
✗ Branch 1 not taken.
4306 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25742
25743
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 4240 times.
✓ Branch 2 taken 4174 times.
✓ Branch 3 taken 132 times.
4306 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25744
25745
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4306 times.
✓ Branch 2 taken 4306 times.
✗ Branch 3 not taken.
4306 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25746
25747 4306 putscr(scrollbuf, 0, 0, oldscr);
25748 4306 putscr(scrollbuf, 256, 0, newscr);
25749 4306 break;
25750 }
25751
25752 10388 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
25753 10388 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
25754
25755 10388 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
25756 10388 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
25757
25758
2/2
✓ Branch 0 taken 9527 times.
✓ Branch 1 taken 861 times.
10388 if(get_bit(quest_rules, qr_FFCSCROLL))
25759 {
25760 861 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
25761 861 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
25762 861 }
25763
25764
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 10322 times.
10388 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
25765
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 10256 times.
10388 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
25766
25767 //push blocks
25768 10388 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
25769 10388 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
25770
2/2
✓ Branch 0 taken 9527 times.
✓ Branch 1 taken 861 times.
10388 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
25771 {
25772 861 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
25773 861 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
25774 861 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
25775 861 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
25776 861 }
25777
25778 10388 do_walkflags(framebuf, oldscr, tx2, ty2,3); //show walkflags if the cheat is on
25779 10388 do_walkflags(framebuf, newscr, tx, ty,2);
25780
25781 10388 do_effectflags(framebuf, oldscr, tx2, ty2,3); //show effectflags if the cheat is on
25782 10388 do_effectflags(framebuf, newscr, tx, ty,2);
25783
25784
25785 10388 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
25786 10388 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
25787 10388 herostep();
25788
25789
4/6
✓ Branch 0 taken 10388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10388 times.
✓ Branch 4 taken 10388 times.
✓ Branch 5 taken 10388 times.
10388 if((z > 0 || fakez > 0) && (!get_bit(quest_rules,qr_SHADOWSFLICKER) || frame&1))
25790 {
25791 20776 drawshadow(framebuf, get_bit(quest_rules, qr_TRANSSHADOWS) != 0);
25792 20776 }
25793
25794
4/4
✓ Branch 0 taken 7380 times.
✓ Branch 1 taken 3008 times.
✓ Branch 2 taken 3858 times.
✓ Branch 3 taken 3522 times.
10388 if(!isdungeon() || get_bit(quest_rules,qr_FREEFORM))
25795 {
25796 6866 draw_under(framebuf); //draw the ladder or raft
25797 6866 decorations.draw2(framebuf, true);
25798 6866 draw(framebuf); //Hero
25799 6866 decorations.draw(framebuf, true);
25800 6866 }
25801
25802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10388 times.
10388 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
25803
25804 10388 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
25805 10388 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
25806
2/2
✓ Branch 0 taken 9562 times.
✓ Branch 1 taken 826 times.
10388 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25807 {
25808 826 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
25809 826 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
25810 826 }
25811 10388 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
25812 10388 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
25813 10388 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
25814
25815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10388 times.
10388 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
25816
25817 10388 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
25818 10388 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
25819
2/2
✓ Branch 0 taken 9562 times.
✓ Branch 1 taken 826 times.
10388 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25820 {
25821 826 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
25822 826 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
25823 826 }
25824 10388 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
25825 10388 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
25826 10388 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
25827
25828
25829
1/2
✓ Branch 0 taken 10388 times.
✗ Branch 1 not taken.
10388 if(msg_bg_display_buf->clip == 0)
25830 {
25831 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25832 }
25833
1/2
✓ Branch 0 taken 10388 times.
✗ Branch 1 not taken.
10388 if(msg_portrait_display_buf->clip == 0)
25834 {
25835 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25836 }
25837
1/2
✓ Branch 0 taken 10388 times.
✗ Branch 1 not taken.
10388 if(msg_txt_display_buf->clip == 0)
25838 {
25839 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25840 }
25841
25842
4/6
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 9527 times.
✓ Branch 2 taken 861 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 861 times.
10388 if(get_bit(quest_rules, qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
25843 {
25844 clear_to_color(darkscr_bmp_curscr, game->get_darkscr_color());
25845 clear_to_color(darkscr_bmp_curscr_trans, game->get_darkscr_color());
25846 clear_to_color(darkscr_bmp_scrollscr, game->get_darkscr_color());
25847 clear_to_color(darkscr_bmp_scrollscr_trans, game->get_darkscr_color());
25848 calc_darkroom_combos(true);
25849 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
25850 }
25851
25852
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 9527 times.
✓ Branch 2 taken 826 times.
✓ Branch 3 taken 35 times.
10388 if(get_bit(quest_rules, qr_NEW_DARKROOM) && get_bit(quest_rules, qr_NEWDARK_L6))
25853 {
25854 35 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25855 35 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25856 35 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25857
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(newscr->flags & fDARK)
25858 {
25859 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25860 {
25861 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25862 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25863 }
25864
25865 color_map = &trans_table2;
25866 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25867 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25868 else
25869 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25870 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25871 color_map = &trans_table;
25872 }
25873
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(oldscr->flags & fDARK)
25874 {
25875 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25876 {
25877 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25878 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25879 }
25880
25881 color_map = &trans_table2;
25882 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25883 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25884 else
25885 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25886 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25887 color_map = &trans_table;
25888 }
25889 35 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25890 35 }
25891 10388 put_passive_subscr(framebuf, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
25892
2/2
✓ Branch 0 taken 4675 times.
✓ Branch 1 taken 5713 times.
10388 if(get_bit(quest_rules,qr_SUBSCREENOVERSPRITES))
25893 5713 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
25894
25895
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 9527 times.
✓ Branch 2 taken 826 times.
✓ Branch 3 taken 35 times.
10388 if(get_bit(quest_rules, qr_NEW_DARKROOM) && !get_bit(quest_rules, qr_NEWDARK_L6))
25896 {
25897 826 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25898 826 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25899 826 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25900
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 if(newscr->flags & fDARK)
25901 {
25902 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25903 {
25904 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25905 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25906 }
25907
25908 color_map = &trans_table2;
25909 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25910 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25911 else
25912 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25913 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25914 color_map = &trans_table;
25915 }
25916
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 if(oldscr->flags & fDARK)
25917 {
25918 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25919 {
25920 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25921 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25922 }
25923
25924 color_map = &trans_table2;
25925 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25926 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25927 else
25928 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25929 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25930 color_map = &trans_table;
25931 }
25932 826 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25933 826 }
25934 10388 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
25935
25936 //end drawing
25937 10388 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25938 10388 advanceframe(true/*,true,false*/);
25939 10388 script_drawing_commands.Clear();
25940 10388 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25941 10388 actiontype lastaction = action;
25942 10388 action=scrolling; FFCore.setHeroAction(scrolling);
25943 10388 FFCore.runF6Engine();
25944 //FFCore.runF6EngineScrolling(newscr,oldscr,tx,ty,tx2,ty2,sx,sy,scrolldir);
25945 10388 action=lastaction; FFCore.setHeroAction(lastaction);
25946 10388 }//end main scrolling loop (2 spaces tab width makes me sad =( )
25947 116 currdmap = olddmap;
25948
25949 116 clear_bitmap(msg_txt_display_buf);
25950 116 set_clip_state(msg_txt_display_buf, 1);
25951 116 clear_bitmap(msg_bg_display_buf);
25952 116 set_clip_state(msg_bg_display_buf, 1);
25953 116 clear_bitmap(msg_portrait_display_buf);
25954 116 set_clip_state(msg_portrait_display_buf, 1);
25955
25956 //Move hero to the other side of the screen if scrolling's not turned on
25957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(get_bit(quest_rules, qr_NOSCROLL))
25958 {
25959 switch(scrolldir)
25960 {
25961 case up:
25962 y = 160;
25963 break;
25964
25965 case down:
25966 y = 0;
25967 break;
25968
25969 case left:
25970 x = 240;
25971 break;
25972
25973 case right:
25974 x = 0;
25975 break;
25976 }
25977 }
25978
25979
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
116 if((z > 0 || fakez > 0) && isSideViewHero())
25980 {
25981 y -= z;
25982 y -= fakez;
25983 z = 0;
25984 fakez = 0;
25985 }
25986
25987 116 set_respawn_point(false);
25988 116 trySideviewLadder();
25989 116 warpx = -1;
25990 116 warpy = -1;
25991
25992 116 screenscrolling = false;
25993 116 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
25994 116 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25995 116 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25996 116 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25997 116 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25998
25999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(destdmap != -1)
26000 {
26001 bool changedlevel = false;
26002 bool changeddmap = false;
26003 if(olddmap != destdmap)
26004 {
26005 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26006 changeddmap = true;
26007 }
26008 if(DMaps[olddmap].level != DMaps[destdmap].level)
26009 {
26010 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26011 changedlevel = true;
26012 }
26013 dlevel = DMaps[destdmap].level;
26014 currdmap = destdmap;
26015 if(changeddmap)
26016 {
26017 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26018 }
26019 if(changedlevel)
26020 {
26021 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26022 }
26023 }
26024
26025 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
26026 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
26027 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
26028 //direction. -DD
26029
26030
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1 times.
116 if(nowinwater)
26031 {
26032 1 SetSwim();
26033 1 hopclk = 0xFF;
26034 1 }
26035
26036 // NES behaviour: Fade to light after scrolling
26037 116 lighting(false, false); // No, we don't need to set naturaldark...
26038
26039 116 init_dmap();
26040 116 putscr(scrollbuf,0,0,newscr);
26041 116 putscrdoors(scrollbuf,0,0,newscr);
26042
26043 // Check for raft flags
26044
4/6
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 115 times.
116 if(action!=rafting && hopclk==0 && !toogam)
26045 {
26046
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
26047 {
26048 sfx(tmpscr->secretsfx);
26049 action=rafting; FFCore.setHeroAction(rafting);
26050 raftclk=0;
26051 }
26052
26053 // Half a tile off?
26054
6/8
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 73 times.
✓ Branch 6 taken 115 times.
✗ Branch 7 not taken.
188 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
26055 {
26056 sfx(tmpscr->secretsfx);
26057 action=rafting; FFCore.setHeroAction(rafting);
26058 raftclk=0;
26059 }
26060 115 }
26061
26062 116 opendoors=0;
26063 116 markBmap(-1);
26064
26065
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 64 times.
116 if(isdungeon())
26066 {
26067
2/3
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
64 switch(tmpscr->door[scrolldir^1])
26068 {
26069 case dOPEN:
26070 case dUNLOCKED:
26071 case dOPENBOSS:
26072 51 dir = scrolldir;
26073
26074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(action!=rafting)
26075 51 stepforward(diagonalMovement?11:12, false);
26076
26077 51 break;
26078
26079 case dSHUTTER:
26080 case d1WAYSHUTTER:
26081 13 dir = scrolldir;
26082
26083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(action!=rafting)
26084 13 stepforward(diagonalMovement?21:24, false);
26085
26086 13 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
26087 13 opendoors=-4;
26088 13 sfx(WAV_DOOR);
26089 13 break;
26090
26091 default:
26092 dir = scrolldir;
26093
26094 if(action!=rafting)
26095 stepforward(diagonalMovement?21:24, false);
26096 }
26097 64 }
26098
26099
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(action == scrolling)
26100 {
26101 action=none; FFCore.setHeroAction(none);
26102 }
26103
26104
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
116 if(action != attacking && action != sideswimattacking)
26105 {
26106 116 charging = 0;
26107 116 tapping = false;
26108 116 }
26109
26110 116 map_bkgsfx(true);
26111
26112
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(newscr->flags2&fSECRET)
26113 {
26114 sfx(newscr->secretsfx);
26115 }
26116
26117 116 playLevelMusic();
26118
26119 116 newscr_clk = frame;
26120 116 activated_timed_warp=false;
26121 116 loadside = scrolldir^1;
26122 116 FFCore.init_combo_doscript();
26123 116 eventlog_mapflags();
26124 116 decorations.animate(); //continue to animate tall grass during scrolling
26125
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 101 times.
116 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
26126 {
26127 //script_drawing_commands.Clear();
26128 15 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
26129 //ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
26130 15 }
26131 116 }
26132
26133
26134
26135 // How much to reduce Hero's damage, taking into account various rings.
26136 32 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
26137 {
26138
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(dmg < 0) return dmg; //Don't reduce healing
26139
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 5 times.
32 if ( get_bit(quest_rules,qr_BROKEN_RING_POWER) )
26140 {
26141 27 int32_t divisor = 1;
26142 27 float percentage = 1;
26143 27 int32_t itemid = current_item_id(itype_ring);
26144 27 bool usering = false;
26145
26146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26147 {
26148 usering = true;
26149 paymagiccost(itemid);
26150 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26151 {
26152 percentage *= itemsbuf[itemid].power/100.0;
26153 }
26154 else
26155 {
26156 divisor *= itemsbuf[itemid].power;
26157 }
26158 }
26159
26160 /* Now for the Peril Ring */
26161 27 itemid = current_item_id(itype_perilring);
26162
26163
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26164 {
26165 usering = true;
26166 paymagiccost(itemid);
26167 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26168 {
26169 percentage *= itemsbuf[itemid].power/100.0;
26170 }
26171 else
26172 {
26173 divisor *= itemsbuf[itemid].power;
26174 }
26175 }
26176
26177 // Ring divisor of 0 = no damage. -L
26178
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26179 return 0;
26180
26181
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
26182
26183
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
26184
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26185
26186 }
26187 else
26188 {
26189 5 double divisor = 1;
26190 5 double percentage = 1;
26191 5 int32_t itemid = current_item_id(itype_ring);
26192 5 bool usering = false;
26193
26194
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
5 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26195 {
26196 1 usering = true;
26197 1 paymagiccost(itemid);
26198
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26199 {
26200 1 double perc = itemsbuf[itemid].power/100.0;
26201
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26202 1 percentage *= perc;
26203 1 }
26204 else
26205 {
26206 if(itemsbuf[itemid].power < 0)
26207 divisor /= -(itemsbuf[itemid].power);
26208 else divisor *= itemsbuf[itemid].power;
26209 }
26210 1 }
26211
26212 /* Now for the Peril Ring */
26213 5 itemid = current_item_id(itype_perilring);
26214
26215
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
5 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26216 {
26217 usering = true;
26218 paymagiccost(itemid);
26219 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26220 {
26221 double perc = itemsbuf[itemid].power/100.0;
26222 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26223 percentage *= perc;
26224 }
26225 else
26226 {
26227 if(itemsbuf[itemid].power < 0)
26228 divisor /= -(itemsbuf[itemid].power);
26229 else divisor *= itemsbuf[itemid].power;
26230 }
26231 }
26232
26233 // Ring divisor of 0 = no damage. -L
26234
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
5 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26235 return 0;
26236
26237 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
26238
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26239 }
26240 32 }
26241
26242 // Should swinging the hammer make the 'pound' sound?
26243 // Or is Hero just hitting air?
26244 bool HeroClass::sideviewhammerpound()
26245 {
26246 int32_t wx=0,wy=0;
26247
26248 switch(dir)
26249 {
26250 case up:
26251 wx=-1;
26252 wy=-15;
26253
26254 if(isSideViewHero()) wy+=8;
26255
26256 break;
26257
26258 case down:
26259 wx=8;
26260 wy=28;
26261
26262 if(isSideViewHero()) wy-=8;
26263
26264 break;
26265
26266 case left:
26267 wx=-8;
26268 wy=14;
26269
26270 if(isSideViewHero()) wy+=8;
26271
26272 break;
26273
26274 case right:
26275 wx=21;
26276 wy=14;
26277
26278 if(isSideViewHero()) wy+=8;
26279
26280 break;
26281 }
26282
26283 if(!isSideViewHero())
26284 {
26285 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
26286 }
26287
26288 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26289
26290 if(dir==left || dir==right)
26291 {
26292 wx+=16;
26293
26294 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26295 }
26296
26297 return false;
26298 }
26299
26300 /************************************/
26301 /******** More Items Code *********/
26302 /************************************/
26303
26304 // The following are only used for Hero damage. Damage is in quarter hearts.
26305 20 int32_t enemy_dp(int32_t index)
26306 {
26307 20 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
26308 }
26309
26310 7 int32_t ewpn_dp(int32_t index)
26311 {
26312 7 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
26313 }
26314
26315 int32_t lwpn_dp(int32_t index)
26316 {
26317 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
26318 }
26319
26320 314181 bool checkbunny(int32_t itemid)
26321 {
26322
1/4
✓ Branch 0 taken 314181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
314181 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
26323 }
26324
26325 263383 bool usesSwordJinx(int32_t itemid)
26326 {
26327 263383 itemdata const& it = itemsbuf[itemid];
26328 263383 bool ret = (it.family==itype_sword);
26329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 263383 times.
263383 if(it.flags & ITEM_FLIP_JINX) return !ret;
26330 263383 return ret;
26331 263383 }
26332 260591 bool checkitem_jinx(int32_t itemid)
26333 {
26334 260591 itemdata const& it = itemsbuf[itemid];
26335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260591 times.
260591 if(it.flags & ITEM_JINX_IMMUNE) return true;
26336
2/2
✓ Branch 0 taken 49893 times.
✓ Branch 1 taken 210698 times.
260591 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
26337 210698 return HeroItemClk() == 0;
26338 260591 }
26339
26340 10470 int32_t Bweapon(int32_t pos)
26341 {
26342
3/4
✓ Branch 0 taken 10470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✓ Branch 3 taken 10318 times.
10470 if(pos < 0 || current_subscreen_active == NULL)
26343 {
26344 152 return 0;
26345 }
26346
26347 10318 int32_t p=-1;
26348
26349
4/4
✓ Branch 0 taken 4794 times.
✓ Branch 1 taken 418339 times.
✓ Branch 2 taken 4794 times.
✓ Branch 3 taken 418339 times.
423133 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
26350 {
26351
4/4
✓ Branch 0 taken 265305 times.
✓ Branch 1 taken 153034 times.
✓ Branch 2 taken 259781 times.
✓ Branch 3 taken 5524 times.
418339 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
26352 {
26353 5524 p=i;
26354 5524 break;
26355 }
26356 412815 }
26357
26358
2/2
✓ Branch 0 taken 5524 times.
✓ Branch 1 taken 4794 times.
10318 if(p==-1)
26359 {
26360 4794 return 0;
26361 }
26362
26363 5524 int32_t actualItem = current_subscreen_active->objects[p].d8;
26364 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
26365 5524 int32_t family = -1;
26366 5524 bool bow = false;
26367
26368
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5518 times.
5524 if(actualItem)
26369 {
26370 6 bool select = false;
26371
26372
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 switch(itemsbuf[actualItem-1].family)
26373 {
26374 case itype_bomb:
26375 if((game->get_bombs() ||
26376 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26377 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
26378 current_item_power(itype_bombbag))
26379 {
26380 select=true;
26381 }
26382
26383 break;
26384
26385 case itype_bowandarrow:
26386 case itype_arrow:
26387 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
26388 {
26389 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26390 select=true;
26391 }
26392
26393 break;
26394
26395 case itype_letterpotion:
26396 /*if(current_item_id(itype_potion)>-1)
26397 {
26398 select=true;
26399 }
26400 else if(current_item_id(itype_letter)>-1)
26401 {
26402 select=true;
26403 }*/
26404 break;
26405
26406 case itype_sbomb:
26407 {
26408 int32_t bombbagid = current_item_id(itype_bombbag);
26409
26410 if((game->get_sbombs() ||
26411 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26412 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
26413 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26414 {
26415 select=true;
26416 }
26417
26418 break;
26419 }
26420
26421 case itype_sword:
26422 {
26423 if(!get_bit(quest_rules,qr_SELECTAWPN))
26424 break;
26425
26426 select=true;
26427 }
26428 break;
26429
26430 default:
26431 6 select=true;
26432 6 }
26433
26434
2/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
26435 {
26436 directItem = actualItem-1;
26437
26438 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
26439
26440 return actualItem-1+(bow?0xF000:0);
26441 }
26442 6 else return 0;
26443 }
26444
26445 5518 directItem = -1;
26446
26447
6/6
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 3632 times.
✓ Branch 3 taken 351 times.
✓ Branch 4 taken 350 times.
✓ Branch 5 taken 394 times.
5518 switch(current_subscreen_active->objects[p].d1)
26448 {
26449 case itype_bomb:
26450 {
26451 741 int32_t bombid = current_item_id(itype_bomb);
26452
26453
3/4
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 352 times.
1093 if((game->get_bombs() ||
26454 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26455
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 352 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
352 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
26456 352 current_item_power(itype_bombbag))
26457 {
26458 389 family=itype_bomb;
26459 389 }
26460
26461 741 break;
26462 }
26463
26464 case itype_bowandarrow:
26465 case itype_arrow:
26466
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
26467 {
26468 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26469 family=itype_arrow;
26470 }
26471
26472 351 break;
26473
26474 case itype_letterpotion:
26475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if(current_item_id(itype_potion)>-1)
26476 {
26477 family=itype_potion;
26478 }
26479
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 else if(current_item_id(itype_letter)>-1)
26480 {
26481 family=itype_letter;
26482 }
26483
26484 350 break;
26485
26486 case itype_sbomb:
26487 {
26488 50 int32_t bombbagid = current_item_id(itype_bombbag);
26489 50 int32_t sbombid = current_item_id(itype_sbomb);
26490
26491
1/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 if((game->get_sbombs() ||
26492 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
26494
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26495 {
26496 family=itype_sbomb;
26497 }
26498
26499 50 break;
26500 }
26501
26502 case itype_sword:
26503 {
26504
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!get_bit(quest_rules,qr_SELECTAWPN))
26505 break;
26506
26507 394 family=itype_sword;
26508 }
26509 394 break;
26510
26511 default:
26512 3632 family=current_subscreen_active->objects[p].d1;
26513 3632 }
26514
26515
2/2
✓ Branch 0 taken 4415 times.
✓ Branch 1 taken 1103 times.
5518 if(family==-1)
26516 1103 return 0;
26517
26518
2/2
✓ Branch 0 taken 747800 times.
✓ Branch 1 taken 2591 times.
750391 for(int32_t j=0; j<MAXITEMS; j++)
26519 {
26520 // Find the item that matches this subscreen object.
26521
5/6
✓ Branch 0 taken 9729 times.
✓ Branch 1 taken 738071 times.
✓ Branch 2 taken 1824 times.
✓ Branch 3 taken 7905 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1824 times.
747800 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
26522 {
26523 1824 return j+(bow?0xF000:0);
26524 }
26525 745976 }
26526
26527 2591 return 0;
26528 10470 }
26529
26530 31 int32_t BWeapon_to_Pos(int32_t bweapon)
26531 {
26532
2/2
✓ Branch 0 taken 3132 times.
✓ Branch 1 taken 12 times.
3144 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
26533 {
26534
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 3113 times.
3132 if (Bweapon(i) == bweapon)
26535 {
26536 19 return i;
26537 }
26538 3113 }
26539 12 return -1;
26540 31 }
26541
26542 void stopCaneOfByrna()
26543 {
26544 for(int32_t i=0; i<Lwpns.Count(); i++)
26545 {
26546 weapon *w = ((weapon*)Lwpns.spr(i));
26547 if(w->id==wCByrna)
26548 w->dead=1;
26549 }
26550 }
26551
26552 /* Crashes if used by ffscript.cpp, in case LINKITEMD
26553 void stopCaneOfByrna()
26554 {
26555 byte prnt_cane = -1;
26556 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
26557 prnt_cane = ew->parentitem;
26558 for(int32_t i=0; i<Lwpns.Count(); i++)
26559 {
26560 weapon *w = ((weapon*)Lwpns.spr(i));
26561
26562 if(w->id==wCByrna)
26563 {
26564 w->dead=1;
26565 }
26566 }
26567 if ( prnt_cane > -1 )
26568 {
26569 stop_sfx(itemsbuf[prnt_cane].usesound);
26570 }
26571 }
26572 */
26573 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
26574 77603 void HeroClass::cleanupByrna()
26575 {
26576
1/2
✓ Branch 0 taken 77603 times.
✗ Branch 1 not taken.
77603 if ( last_cane_of_byrna_item_id > -1 )
26577 {
26578 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
26579 if ( !(Lwpns.idCount(wCByrna)) )
26580 {
26581 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
26582 last_cane_of_byrna_item_id = -1;
26583 }
26584 }
26585 77603 }
26586
26587 // Used to find out if an item family is attached to one of the buttons currently pressed.
26588 9130 bool isWpnPressed(int32_t itype)
26589 {
26590 //0xFFF for subscreen overrides
26591 //Will crash on win10 without it! -Z
26592
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9130 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
26593
4/4
✓ Branch 0 taken 7875 times.
✓ Branch 1 taken 1255 times.
✓ Branch 2 taken 2889 times.
✓ Branch 3 taken 4986 times.
9130 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
26594
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4144 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
26595
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4144 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
26596 4144 return false;
26597 9130 }
26598
26599 75737 int32_t getWpnPressed(int32_t itype)
26600 {
26601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75737 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75737 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75737 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75737 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26603
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75737 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75737 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26604
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75737 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75737 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26605
26606 75737 return -1;
26607 75737 }
26608
26609 79964 int32_t getRocsPressed()
26610 {
26611 79964 int32_t jumpid = current_item_id(itype_rocs,true,true);
26612
26613
2/2
✓ Branch 0 taken 12370 times.
✓ Branch 1 taken 67594 times.
79964 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
26614
26615
2/2
✓ Branch 0 taken 67594 times.
✓ Branch 1 taken 12370 times.
79964 if (jumpid != -1)
26616 {
26617 12370 itemdata const& itm = itemsbuf[jumpid];
26618
26619 12370 byte intbtn = byte(itm.misc2&0xFF);
26620
1/2
✓ Branch 0 taken 12370 times.
✗ Branch 1 not taken.
12370 if(getIntBtnInput(intbtn, false, true, false, false, true))
26621 return jumpid; //not pressed
26622 12370 }
26623
26624
4/4
✓ Branch 0 taken 12370 times.
✓ Branch 1 taken 67594 times.
✓ Branch 2 taken 11403 times.
✓ Branch 3 taken 967 times.
79964 if((itype_rocs==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78997 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78997 if((itype_rocs==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26626
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78997 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78997 if((itype_rocs==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78997 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78997 if((itype_rocs==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26628
26629 78997 return -1;
26630 79964 }
26631
26632 bool isItmPressed(int32_t itmid)
26633 {
26634 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
26635 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
26636 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
26637 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
26638 return false;
26639 }
26640
26641 1 void selectNextAWpn(int32_t type)
26642 {
26643
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!get_bit(quest_rules,qr_SELECTAWPN))
26644 return;
26645
26646
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26647 1 Awpn = Bweapon(ret);
26648 1 directItemA = directItem;
26649 1 game->awpn = ret;
26650 1 }
26651
26652 2 void selectNextBWpn(int32_t type)
26653 {
26654
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26655 2 Bwpn = Bweapon(ret);
26656 2 directItemB = directItem;
26657 2 game->bwpn = ret;
26658 2 }
26659
26660 void selectNextXWpn(int32_t type)
26661 {
26662 if(!get_bit(quest_rules,qr_SET_XBUTTON_ITEMS)) return;
26663 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26664 Xwpn = Bweapon(ret);
26665 directItemX = directItem;
26666 game->xwpn = ret;
26667 }
26668
26669 void selectNextYWpn(int32_t type)
26670 {
26671 if(!get_bit(quest_rules,qr_SET_YBUTTON_ITEMS)) return;
26672 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
26673 Ywpn = Bweapon(ret);
26674 directItemY = directItem;
26675 game->ywpn = ret;
26676 }
26677
26678 960 void verifyAWpn()
26679 {
26680
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 933 times.
960 if ( (game->forced_awpn != -1) )
26681 {
26682 27 return;
26683 }
26684
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 225 times.
933 if(!get_bit(quest_rules,qr_SELECTAWPN))
26685 {
26686 708 Awpn = selectSword();
26687 708 game->awpn = 0xFF;
26688 708 }
26689 else
26690 {
26691 225 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
26692 225 Awpn = Bweapon(game->awpn);
26693 225 directItemA = directItem;
26694 }
26695 960 }
26696
26697 927 void verifyBWpn()
26698 {
26699
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 901 times.
927 if ( (game->forced_bwpn != -1) )
26700 {
26701 26 return;
26702 }
26703 901 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
26704 901 Bwpn = Bweapon(game->bwpn);
26705 901 directItemB = directItem;
26706 927 }
26707
26708 927 void verifyXWpn()
26709 {
26710
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 901 times.
927 if ( (game->forced_xwpn != -1) )
26711 {
26712 26 return;
26713 }
26714
2/2
✓ Branch 0 taken 837 times.
✓ Branch 1 taken 64 times.
901 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
26715 64 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
26716 837 else game->xwpn = -1;
26717 901 Xwpn = Bweapon(game->xwpn);
26718 901 directItemX = directItem;
26719 927 }
26720
26721 927 void verifyYWpn()
26722 {
26723
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 901 times.
927 if ( (game->forced_ywpn != -1) )
26724 {
26725 26 return;
26726 }
26727
2/2
✓ Branch 0 taken 837 times.
✓ Branch 1 taken 64 times.
901 if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS))
26728 64 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
26729 837 else game->ywpn = -1;
26730 901 Ywpn = Bweapon(game->ywpn);
26731 901 directItemY = directItem;
26732 927 }
26733
26734 927 void verifyBothWeapons()
26735 {
26736 927 verifyAWpn();
26737 927 verifyBWpn();
26738 927 verifyXWpn();
26739 927 verifyYWpn();
26740 927 }
26741
26742 1278 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3)
26743 {
26744 //what will be returned when all else fails.
26745 //don't return the forbiddenpos... no matter what -DD
26746
26747 1278 int32_t failpos(0);
26748
26749
6/6
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 348 times.
✓ Branch 2 taken 875 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 871 times.
1278 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
26750 407 failpos = 0xFF;
26751 871 else failpos = startpos;
26752
26753 // verify startpos
26754
3/4
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 417 times.
✓ Branch 3 taken 861 times.
1278 if(startpos < 0 || startpos >= 0xFF)
26755 417 startpos = 0;
26756
26757
2/2
✓ Branch 0 taken 1218 times.
✓ Branch 1 taken 60 times.
1278 if(current_subscreen_active == NULL)
26758 60 return failpos;
26759
26760
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1215 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
1218 if(type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT)
26761 {
26762 1215 int32_t wpn = Bweapon(startpos);
26763
26764
6/8
✓ Branch 0 taken 823 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 819 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 819 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 819 times.
1215 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
26765 {
26766 819 return startpos;
26767 }
26768 396 }
26769
26770 399 int32_t p=-1;
26771 399 int32_t curpos = startpos;
26772 399 int32_t firstValidPos=-1;
26773
26774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7884 times.
7884 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26775 {
26776
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 4482 times.
7884 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26777 {
26778
4/4
✓ Branch 0 taken 4045 times.
✓ Branch 1 taken 437 times.
✓ Branch 2 taken 3646 times.
✓ Branch 3 taken 399 times.
4482 if(firstValidPos==-1 && current_subscreen_active->objects[i].d3>=0)
26779 {
26780 399 firstValidPos=i;
26781 399 }
26782
26783
2/2
✓ Branch 0 taken 4083 times.
✓ Branch 1 taken 399 times.
4482 if(current_subscreen_active->objects[i].d3==curpos)
26784 {
26785 399 p=i;
26786 399 break;
26787 }
26788 4083 }
26789 7485 }
26790
26791
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 if(p == -1)
26792 {
26793 //can't find the current position
26794 // Switch to a valid weapon if there is one; otherwise,
26795 // the selector can simply disappear
26796 if(firstValidPos>=0)
26797 {
26798 return current_subscreen_active->objects[firstValidPos].d3;
26799 }
26800 //FAILURE
26801 else
26802 {
26803 return failpos;
26804 }
26805 }
26806
26807 //remember we've been here
26808 399 set<int32_t> oldPositions;
26809
1/2
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
399 oldPositions.insert(curpos);
26810
26811 //1. Perform any shifts required by the above
26812 //2. If that's not possible, go to position 1 and reset the b weapon.
26813 //2a. -if we arrive at a position we've already visited, give up and stay there
26814 //3. Get the weapon at the new slot
26815 //4. If it's not possible, go to step 1.
26816
26817 3369 for(;;)
26818 {
26819 //shift
26820
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
3369 switch(type)
26821 {
26822 case SEL_LEFT:
26823 case SEL_VERIFY_LEFT:
26824 curpos = current_subscreen_active->objects[p].d6;
26825 break;
26826
26827 case SEL_RIGHT:
26828 case SEL_VERIFY_RIGHT:
26829 3369 curpos = current_subscreen_active->objects[p].d7;
26830 3369 break;
26831
26832 case SEL_DOWN:
26833 curpos = current_subscreen_active->objects[p].d5;
26834 break;
26835
26836 case SEL_UP:
26837 curpos = current_subscreen_active->objects[p].d4;
26838 break;
26839 }
26840
26841 //find our new position
26842 3369 p = -1;
26843
26844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78844 times.
78844 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26845 {
26846
2/2
✓ Branch 0 taken 26125 times.
✓ Branch 1 taken 52719 times.
78844 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26847 {
26848
2/2
✓ Branch 0 taken 49350 times.
✓ Branch 1 taken 3369 times.
52719 if(current_subscreen_active->objects[i].d3==curpos)
26849 {
26850 3369 p=i;
26851 3369 break;
26852 }
26853 49350 }
26854 75475 }
26855
26856
1/2
✓ Branch 0 taken 3369 times.
✗ Branch 1 not taken.
3369 if(p == -1)
26857 {
26858 //can't find the current position
26859 //FAILURE
26860 return failpos;
26861 }
26862
26863 //if we've already been here, give up
26864
4/6
✓ Branch 0 taken 3369 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2988 times.
✓ Branch 5 taken 381 times.
3369 if(oldPositions.find(curpos) != oldPositions.end())
26865 {
26866 381 return failpos;
26867 }
26868
26869 //else, remember we've been here
26870
1/2
✓ Branch 0 taken 2988 times.
✗ Branch 1 not taken.
2988 oldPositions.insert(curpos);
26871
26872 //see if this weapon is acceptable
26873
9/10
✓ Branch 0 taken 2988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✓ Branch 3 taken 2905 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 47 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 18 times.
2988 if(Bweapon(curpos) != 0 && curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
26874 18 return curpos;
26875
26876 //keep going otherwise
26877 }
26878 1278 }
26879
26880 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
26881 723 int32_t selectSword()
26882 {
26883 723 auto ret = current_item_id(itype_sword);
26884
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 474 times.
723 if(ret == -1) return 0;
26885 474 return ret;
26886 723 }
26887
26888 // Adding code here for allowing hardcoding a button to a specific itemclass.
26889 int32_t selectItemclass(int32_t itemclass)
26890 {
26891 int32_t ret = current_item_id(itemclass);
26892
26893 if(ret == -1)
26894 ret = 0;
26895
26896 return ret;
26897 }
26898
26899 // Used for the 'Pickup Hearts' item pickup condition.
26900 7 bool canget(int32_t id)
26901 {
26902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
26903 }
26904
26905 void dospecialmoney(int32_t index)
26906 {
26907 int32_t tmp=currscr>=128?1:0;
26908 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
26909
26910 switch(tmpscr[tmp].room)
26911 {
26912 case rINFO: // pay for info
26913 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
26914 {
26915
26916
26917 if(!current_item_power(itype_wallet))
26918 {
26919 if (game->get_spendable_rupies() < abs(prices[priceindex]))
26920 return;
26921 int32_t tmpprice = -abs(prices[priceindex]);
26922 int32_t total = game->get_drupy()-tmpprice;
26923 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26924 game->set_drupy(game->get_drupy()-total);
26925 //game->change_drupy(-abs(prices[priceindex]));
26926 }
26927 if ( current_item_power(itype_wallet)>0 )
26928 {
26929 game->change_drupy(0);
26930 }
26931 }
26932 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
26933 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
26934 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
26935 clear_bitmap(pricesdisplaybuf);
26936 set_clip_state(pricesdisplaybuf, 1);
26937 items.del(0);
26938
26939 for(int32_t i=0; i<items.Count(); i++)
26940 ((item*)items.spr(i))->pickup=ipDUMMY;
26941
26942 // Prevent the prices from being displayed anymore
26943 for(int32_t i=0; i<3; i++)
26944 {
26945 prices[i] = 0;
26946 }
26947
26948 break;
26949
26950 case rMONEY: // secret money
26951 {
26952 ((item*)items.spr(0))->pickup = ipDUMMY;
26953
26954 prices[0] = tmpscr[tmp].catchall;
26955 if (!current_item_power(itype_wallet))
26956 game->change_drupy(prices[0]);
26957 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
26958
26959 putprices(false);
26960 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26961 break;
26962 }
26963
26964 case rGAMBLE: // gamble
26965 {
26966 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
26967
26968 unsigned si=(zc_oldrand()%24)*3;
26969
26970 for(int32_t i=0; i<3; i++)
26971 prices[i]=gambledat[si++];
26972
26973 game->set_drupy(game->get_drupy()+prices[priceindex]);
26974 putprices(true);
26975
26976 for(int32_t i=1; i<4; i++)
26977 ((item*)items.spr(i))->pickup=ipDUMMY;
26978 }
26979 break;
26980
26981 case rBOMBS:
26982 {
26983 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
26984 return;
26985
26986 int32_t price = -tmpscr[tmp].catchall;
26987 int32_t wmedal = current_item_id(itype_wealthmedal);
26988 if(wmedal >= 0)
26989 {
26990 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
26991 price*=(itemsbuf[wmedal].misc1/100.0);
26992 else
26993 price+=itemsbuf[wmedal].misc1;
26994 }
26995
26996 int32_t total = game->get_drupy()-price;
26997 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26998 game->set_drupy(game->get_drupy()-total);
26999 //game->set_drupy(game->get_drupy()+price);
27000 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27001 game->change_maxbombs(4);
27002 game->set_bombs(game->get_maxbombs());
27003 {
27004 int32_t div = zinit.bomb_ratio;
27005
27006 if(div > 0)
27007 game->change_maxcounter(4/div, 6);
27008 }
27009
27010 //also give Hero an actual Bomb item
27011 for(int32_t i=0; i<MAXITEMS; i++)
27012 {
27013 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
27014 getitem(i, true, true);
27015 }
27016
27017 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
27018 fadeclk=66;
27019 dismissmsg();
27020 clear_bitmap(pricesdisplaybuf);
27021 set_clip_state(pricesdisplaybuf, 1);
27022 // putscr(scrollbuf,0,0,tmpscr);
27023 verifyBothWeapons();
27024 break;
27025 }
27026
27027 case rARROWS:
27028 {
27029 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
27030 return;
27031
27032 int32_t price = -tmpscr[tmp].catchall;
27033 int32_t wmedal = current_item_id(itype_wealthmedal);
27034 if(wmedal >= 0)
27035 {
27036 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
27037 price*=(itemsbuf[wmedal].misc1/100.0);
27038 else
27039 price+=itemsbuf[wmedal].misc1;
27040 }
27041
27042 int32_t total = game->get_drupy()-price;
27043 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27044 game->set_drupy(game->get_drupy()-total);
27045
27046 //game->set_drupy(game->get_drupy()+price);
27047 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27048 game->change_maxarrows(10);
27049 game->set_arrows(game->get_maxarrows());
27050 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
27051 fadeclk=66;
27052 dismissmsg();
27053 clear_bitmap(pricesdisplaybuf);
27054 set_clip_state(pricesdisplaybuf, 1);
27055 // putscr(scrollbuf,0,0,tmpscr);
27056 verifyBothWeapons();
27057 break;
27058 }
27059
27060 case rSWINDLE:
27061 if(items.spr(index)->id==iRupy)
27062 {
27063 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
27064 return;
27065 int32_t tmpprice = -tmpscr[tmp].catchall;
27066 int32_t total = game->get_drupy()-tmpprice;
27067 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27068 game->set_drupy(game->get_drupy()-total);
27069 }
27070 else
27071 {
27072 if(game->get_maxlife()<=game->get_hp_per_heart())
27073 return;
27074
27075 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
27076 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
27077 }
27078
27079 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27080 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
27081 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
27082 fadeclk=66;
27083 dismissmsg();
27084 clear_bitmap(pricesdisplaybuf);
27085 set_clip_state(pricesdisplaybuf, 1);
27086 // putscr(scrollbuf,0,0,tmpscr);
27087 break;
27088 }
27089 }
27090
27091 211 void getitem(int32_t id, bool nosound, bool doRunPassive)
27092 {
27093
1/2
✓ Branch 0 taken 211 times.
✗ Branch 1 not taken.
211 if(id<0)
27094 {
27095 return;
27096 }
27097
27098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
211 if (replay_is_active())
27099
1/2
✓ Branch 0 taken 211 times.
✗ Branch 1 not taken.
211 replay_step_comment(fmt::format("getitem {}", item_string[id]));
27100
27101
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 3 times.
211 if(get_bit(quest_rules,qr_SCC_ITEM_COMBINES_ITEMS))
27102 {
27103 3 int32_t nextitem = -1;
27104 3 do
27105 {
27106 3 nextitem = -1;
27107
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
27108 // Item upgrade routine.
27109 {
27110
27111 for(int32_t i=0; i<MAXITEMS; i++)
27112 {
27113 // Find the item which is as close to this item's fam_type as possible.
27114 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
27115 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27116 {
27117 nextitem = i;
27118 }
27119 }
27120
27121 if(nextitem>-1)
27122 {
27123 id = nextitem;
27124 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27125 break; //no looping
27126 }
27127 }
27128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 } while(nextitem > -1);
27129 3 }
27130
27131 211 itemdata const& idat = itemsbuf[id&0xFF];
27132 // if(idat.family!=0xFF) //1.92 compat... that already should be changed to 'itype_misc'? Blehg, hate this! -Em
27133 {
27134
4/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 104 times.
211 if(idat.flags & ITEM_GAMEDATA && idat.family != itype_triforcepiece)
27135 {
27136 // Fix boomerang sounds.
27137 104 int32_t itemid = current_item_id(idat.family);
27138
27139
4/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_nayruslove
27140
3/6
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
20 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
27141 21 && sfx_allocated(itemsbuf[itemid].usesound)
27142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 && idat.usesound != itemsbuf[itemid].usesound)
27143 {
27144 stop_sfx(itemsbuf[itemid].usesound);
27145 cont_sfx(idat.usesound);
27146 }
27147
27148 104 int32_t curitm = current_item_id(idat.family);
27149
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
104 if(!get_bit(quest_rules,qr_KEEPOLD_APPLIES_RETROACTIVELY)
27150
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
27151 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
27152 {
27153 104 game->set_item(id,true);
27154 104 passiveitem_script(id, doRunPassive);
27155 104 }
27156
27157
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 28 times.
104 if(!(idat.flags & ITEM_KEEPOLD))
27158 {
27159
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
28 if(!get_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
27160 {
27161 7 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
27162 7 }
27163 28 }
27164
27165 // NES consistency: replace all flying boomerangs with the current boomerang.
27166
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 8 times.
104 if(idat.family==itype_brang)
27167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 for(int32_t i=0; i<Lwpns.Count(); i++)
27168 {
27169 weapon *w = ((weapon*)Lwpns.spr(i));
27170
27171 if(w->id==wBrang)
27172 {
27173 w->LOADGFX(idat.wpn);
27174 }
27175 8 }
27176 104 }
27177
27178
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 112 times.
211 if(idat.count!=-1)
27179 {
27180
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 7 times.
112 if(idat.setmax)
27181 {
27182 // Bomb bags are a special case; they may be set not to increase super bombs
27183
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
7 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
27184 {
27185 int32_t max = game->get_maxbombs();
27186
27187 if(max<idat.max) max=idat.max;
27188
27189 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
27190 }
27191 else
27192 {
27193 7 int32_t max = game->get_maxcounter(idat.count);
27194
27195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(max<idat.max) max=idat.max;
27196
27197
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5 times.
7 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
27198 }
27199 7 }
27200
27201 // Amount is an uint16_t, but the range is -9999 to 16383
27202 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
27203
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 100 times.
112 if(idat.amount&0x3FFF)
27204 {
27205
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 20 times.
100 if(idat.amount&0x8000)
27206 160 game->set_dcounter(
27207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27208 else
27209 {
27210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
27211 game->set_counter(0, idat.count);
27212 else
27213 // This is too confusing to try and change...
27214
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
20 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
27215 }
27216 100 }
27217 112 }
27218 }
27219
27220
3/4
✓ Branch 0 taken 211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 121 times.
211 if(idat.playsound&&!nosound)
27221 {
27222 121 sfx(idat.playsound);
27223 121 }
27224
27225 //add lower-level items
27226
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 2 times.
211 if(idat.flags&ITEM_GAINOLD)
27227 {
27228
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 for(int32_t i=idat.fam_type-1; i>0; i--)
27229 {
27230 1 int32_t potid = getItemID(itemsbuf, idat.family, i);
27231
27232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(potid != -1)
27233 {
27234 1 game->set_item(potid, true);
27235 1 }
27236 1 }
27237 2 }
27238
27239
8/14
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
211 switch(idat.family)
27240 {
27241 case itype_itmbundle:
27242 {
27243 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27244 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27245 bool pscript = (idat.flags & ITEM_FLAG1);
27246 for(auto q = 0; q < 10; ++q)
27247 {
27248 if(unsigned(ids[q]) >= MAXITEMS) continue;
27249 if(pscript)
27250 collectitem_script(ids[q]);
27251 getitem(ids[q], true, true);
27252 }
27253 }
27254 break;
27255
27256 case itype_progressive_itm:
27257 {
27258 int32_t newid = get_progressive_item(idat);
27259 if(newid > -1)
27260 getitem(newid, nosound, true);
27261 }
27262 break;
27263
27264 case itype_bottlefill:
27265 {
27266 if(idat.misc1)
27267 {
27268 game->fillBottle(idat.misc1);
27269 }
27270 }
27271 break;
27272
27273 case itype_clock:
27274 {
27275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27276 break;
27277
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
27278 break;
27279 1 setClock(watch=true);
27280
27281
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1 times.
513 for(int32_t i=0; i<eMAXGUYS; i++)
27282 512 clock_zoras[i]=0;
27283
27284 1 clockclk=itemsbuf[id&0xFF].misc1;
27285 1 sfx(idat.usesound);
27286 }
27287 1 break;
27288
27289 case itype_lkey:
27290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
27291 4 break;
27292
27293 case itype_ring:
27294 case itype_magicring:
27295
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27296 {
27297 2 ringcolor(false);
27298 2 }
27299 2 break;
27300
27301 case itype_whispring:
27302 {
27303 if(idat.flags & ITEM_FLAG1)
27304 {
27305 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
27306
27307 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
27308 }
27309
27310 if(idat.power==0)
27311 {
27312 setSwordClk(0);
27313 setItemClk(0);
27314 }
27315
27316 break;
27317 }
27318
27319
27320 case itype_map:
27321 3 game->lvlitems[dlevel]|=liMAP;
27322 3 break;
27323
27324 case itype_compass:
27325 2 game->lvlitems[dlevel]|=liCOMPASS;
27326 2 break;
27327
27328 case itype_bosskey:
27329 1 game->lvlitems[dlevel]|=liBOSSKEY;
27330 1 break;
27331
27332 case itype_fairy:
27333
27334
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
27335
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
27336 2 break;
27337
27338 case itype_heartpiece:
27339 game->change_HCpieces(1);
27340
27341 if(game->get_HCpieces()<game->get_hcp_per_hc())
27342 break;
27343
27344 game->set_HCpieces(0);
27345
27346 getitem(heart_container_id());
27347 break;
27348
27349 case itype_killem:
27350 {
27351 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27352 break;
27353 kill_em_all();
27354 sfx(idat.usesound);
27355 }
27356 break;
27357 }
27358
27359 211 flushItemCache();
27360 211 update_subscreens();
27361 211 load_Sitems(&QMisc);
27362 211 verifyBothWeapons();
27363 211 }
27364
27365 void takeitem(int32_t id)
27366 {
27367 game->set_item(id, false);
27368 itemdata const& idat = itemsbuf[id];
27369
27370 /* Lower the counters! */
27371 if(idat.count!=-1)
27372 {
27373 if(idat.setmax)
27374 {
27375 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
27376 }
27377
27378 if(idat.amount&0x3FFF)
27379 {
27380 if(idat.amount&0x8000)
27381 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27382 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27383 }
27384 }
27385
27386 switch(itemsbuf[id&0xFF].family)
27387 {
27388 // NES consistency: replace all flying boomerangs with the current boomerang.
27389 case itype_brang:
27390 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
27391 {
27392 weapon *w = ((weapon*)Lwpns.spr(i));
27393
27394 if(w->id==wBrang)
27395 {
27396 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
27397 }
27398 }
27399
27400 break;
27401
27402 case itype_itmbundle:
27403 {
27404 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27405 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27406 for(auto q = 0; q < 10; ++q)
27407 {
27408 if(unsigned(ids[q]) >= MAXITEMS) continue;
27409 takeitem(ids[q]);
27410 }
27411 }
27412 break;
27413
27414 case itype_progressive_itm:
27415 {
27416 int32_t newid = get_progressive_item(idat, true);
27417 if(newid > -1)
27418 takeitem(newid);
27419 }
27420 break;
27421
27422 case itype_heartpiece:
27423 if(game->get_maxlife()>game->get_hp_per_heart())
27424 {
27425 if(game->get_HCpieces()==0)
27426 {
27427 game->set_HCpieces(game->get_hcp_per_hc());
27428 takeitem(iHeartC);
27429 }
27430
27431 game->change_HCpieces(-1);
27432 }
27433 break;
27434
27435 case itype_map:
27436 game->lvlitems[dlevel]&=~liMAP;
27437 break;
27438
27439 case itype_compass:
27440 game->lvlitems[dlevel]&=~liCOMPASS;
27441 break;
27442
27443 case itype_bosskey:
27444 game->lvlitems[dlevel]&=~liBOSSKEY;
27445 break;
27446
27447 case itype_lkey:
27448 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
27449 break;
27450
27451 case itype_ring:
27452 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27453 {
27454 ringcolor(false);
27455 }
27456 break;
27457 }
27458 }
27459
27460 // Attempt to pick up an item. (-1 = check items touching Hero.)
27461 79850 void HeroClass::checkitems(int32_t index)
27462 {
27463 79850 int32_t tmp=currscr>=128?1:0;
27464
27465
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 79833 times.
79850 if(index==-1)
27466 {
27467
2/2
✓ Branch 0 taken 17811 times.
✓ Branch 1 taken 79833 times.
97644 for(auto ind = items.Count()-1; ind >= 0; --ind)
27468 {
27469 17811 item* itm = (item*)items.spr(ind);
27470
1/2
✓ Branch 0 taken 17811 times.
✗ Branch 1 not taken.
17811 if(itm->get_forcegrab())
27471 {
27472 checkitems(ind);
27473 }
27474 17811 }
27475
2/2
✓ Branch 0 taken 14647 times.
✓ Branch 1 taken 65186 times.
79833 if(diagonalMovement)
27476 {
27477 14647 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
27478 14647 }
27479 65186 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
27480 79833 }
27481
27482
2/2
✓ Branch 0 taken 609 times.
✓ Branch 1 taken 79241 times.
79850 if(index==-1)
27483 79241 return;
27484
27485 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
27486 // return;
27487 609 item* ptr = (item*)items.spr(index);
27488 609 int32_t pickup = ptr->pickup;
27489 609 int8_t exstate = ptr->pickupexstate;
27490 609 int32_t PriceIndex = ptr->PriceIndex;
27491 609 int32_t id2 = ptr->id;
27492 609 int32_t holdid = ptr->id;
27493 609 int32_t pstr = ptr->pstring;
27494 609 int32_t pstr_flags = ptr->pickup_string_flags;
27495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 609 times.
609 if(ptr->fallclk > 0) return; //Don't pick up a falling item
27496
27497
1/2
✓ Branch 0 taken 609 times.
✗ Branch 1 not taken.
609 if(itemsbuf[id2].family == itype_progressive_itm)
27498 {
27499 int32_t newid = get_progressive_item(itemsbuf[id2]);
27500 if(newid > -1)
27501 {
27502 id2 = newid;
27503 holdid = newid;
27504 pstr = itemsbuf[newid].pstring;
27505 pstr_flags = itemsbuf[newid].pickup_string_flags;
27506 }
27507 }
27508
27509
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 8 times.
609 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
27510
27511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 609 times.
609 if(bottledummy) //Dummy bullshit!
27512 {
27513 if(!game->canFillBottle())
27514 return;
27515 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27516 {
27517 if(!current_item_power(itype_wallet))
27518 {
27519 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27520 int32_t tmpprice = -abs(prices[PriceIndex]);
27521 //game->change_drupy(-abs(prices[priceindex]));
27522 int32_t total = game->get_drupy()-tmpprice;
27523 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27524 game->set_drupy(game->get_drupy()-total);
27525 }
27526 else //infinite wallet
27527 {
27528 game->change_drupy(0);
27529 }
27530 }
27531 boughtsomething=true;
27532 //make the other shop items untouchable after
27533 //you buy something
27534 int32_t count = 0;
27535
27536 for(int32_t i=0; i<3; i++)
27537 {
27538 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
27539 {
27540 ++count;
27541 }
27542 }
27543
27544 for(int32_t i=0; i<items.Count(); i++)
27545 {
27546 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27547 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27548 }
27549
27550 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
27551 id2 = find_bottle_for_slot(slot);
27552 ptr->id = id2;
27553 pstr = 0;
27554 pickup |= ipHOLDUP;
27555 }
27556 else
27557 {
27558 609 std::vector<int32_t> &ev = FFCore.eventData;
27559 609 ev.clear();
27560 609 ev.push_back(id2*10000);
27561 609 ev.push_back(pickup*10000);
27562 609 ev.push_back(pstr*10000);
27563 609 ev.push_back(pstr_flags*10000);
27564 609 ev.push_back(0);
27565 609 ev.push_back(ptr->getUID());
27566 609 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
27567 609 ev.push_back(0);
27568
27569 609 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
27570 609 bool nullify = ev[4] != 0;
27571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 609 times.
609 if(nullify) return;
27572 609 id2 = ev[0]/10000;
27573 609 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
27574 609 pstr = ev[2] / 10000;
27575 609 pstr_flags = ev[3] / 10000;
27576
27577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 609 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
609 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
27578 return; //No picking these up unless you have a bottle to fill!
27579
27580
5/6
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 507 times.
✓ Branch 3 taken 66 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 507 times.
609 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
27581
1/2
✓ Branch 0 taken 507 times.
✗ Branch 1 not taken.
507 if(ptr->id!=iFairyMoving)
27582 // wait for it to stop flashing, doesn't check for other items yet
27583 507 return;
27584
27585
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 3 times.
102 if(pickup&ipENEMY) // item was being carried by enemy
27586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
6 if(more_carried_items()<=1) // 1 includes this own item.
27587 3 hasitem &= ~2;
27588
27589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(pickup&ipDUMMY) // dummy item (usually a rupee)
27590 {
27591 if(pickup&ipMONEY)
27592 dospecialmoney(index);
27593
27594 return;
27595 }
27596
27597
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if(get_bit(quest_rules,qr_HEARTSREQUIREDFIX) && !canget(id2))
27598 return;
27599
27600 102 int32_t nextitem = -1;
27601 102 do
27602 {
27603 102 nextitem = -1;
27604
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
27605 // Item upgrade routine.
27606 {
27607
27608 for(int32_t i=0; i<MAXITEMS; i++)
27609 {
27610 // Find the item which is as close to this item's fam_type as possible.
27611 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
27612 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27613 {
27614 nextitem = i;
27615 }
27616 }
27617
27618 if(nextitem>-1)
27619 {
27620 id2 = nextitem;
27621 if(get_bit(quest_rules,qr_ITEMCOMBINE_NEW_PSTR))
27622 {
27623 pstr = itemsbuf[id2].pstring;
27624 pstr_flags = itemsbuf[id2].pickup_string_flags;
27625 }
27626 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27627 break; //no looping
27628 }
27629 }
27630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 } while(nextitem > -1);
27631
27632
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 8 times.
102 if(pickup&ipCHECK) // check restrictions
27633
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
8 switch(tmpscr[tmp].room)
27634 {
27635 case rSP_ITEM: // special item
27636
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!canget(id2)) // These ones always need the Hearts Required check
27637 return;
27638
27639 7 break;
27640
27641 case rP_SHOP: // potion shop
27642 if(msg_active)
27643 return;
27644 [[fallthrough]];
27645 case rSHOP: // shop
27646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27647 {
27648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!current_item_power(itype_wallet))
27649 {
27650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27651 1 int32_t tmpprice = -abs(prices[PriceIndex]);
27652 //game->change_drupy(-abs(prices[priceindex]));
27653 1 int32_t total = game->get_drupy()-tmpprice;
27654 1 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27655 1 game->set_drupy(game->get_drupy()-total);
27656 1 }
27657 else //infinite wallet
27658 {
27659 game->change_drupy(0);
27660 }
27661 1 }
27662 1 boughtsomething=true;
27663 //make the other shop items untouchable after
27664 //you buy something
27665 1 int32_t count = 0;
27666
27667
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<3; i++)
27668 {
27669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
27670 {
27671 3 ++count;
27672 3 }
27673 3 }
27674
27675
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<items.Count(); i++)
27676 {
27677
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
4 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27678 2 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27679 4 }
27680
27681 1 break;
27682 8 }
27683
27684
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 75 times.
102 if(pickup&ipONETIME) // set mITEM for one-time-only items
27685 {
27686 27 setmapflag(mITEM);
27687
27688 //Okay so having old source files is a godsend. You wanna know why?
27689 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
27690 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
27691 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
27692 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
27693 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
27694
27695 /*
27696 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
27697 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
27698
27699 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
27700 // What is etc?! We need to check for every valid state here. ~Gleeok
27701 if(get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW))
27702 {
27703 // Most older quests need one-time-pickups to not remove special items, etc.
27704 if(tmpscr->room==rGRUMBLE)
27705 {
27706 setmapflag(mSPECIALITEM);
27707 }
27708 }
27709 */
27710 27 }
27711
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 8 times.
75 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
27712
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27713
27714
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if(exstate > -1 && exstate < 32)
27715 {
27716 setxmapflag(1<<exstate);
27717 }
27718
27719
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
27720 {
27721 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
27722 hidden_entrance(0, true, false, -5);
27723 }
27724
27725 102 collectitem_script(id2);
27726 102 getitem(id2, false, true);
27727 }
27728
27729
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 88 times.
102 if(pickup&ipHOLDUP)
27730 {
27731 14 attackclk=0;
27732 14 reset_swordcharge();
27733
27734
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(action!=swimming && !IsSideSwim())
27735 14 reset_hookshot();
27736
27737
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8 times.
14 if(msg_onscreen)
27738 {
27739 8 dismissmsg();
27740 8 }
27741
27742 14 clear_bitmap(pricesdisplaybuf);
27743
27744
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(get_bit(quest_rules, qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
27745 (get_bit(quest_rules, qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
27746 {
27747 14 fadeclk=66;
27748 14 }
27749
27750
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14 if(id2!=iBombs || action==swimming || get_bit(quest_rules,qr_BOMBHOLDFIX))
27751 {
27752 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
27753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(action==swimming)
27754 {
27755 action=waterhold1; FFCore.setHeroAction(waterhold1);
27756 }
27757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(IsSideSwim())
27758 {
27759 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
27760 }
27761 else
27762 {
27763 14 action=landhold1; FFCore.setHeroAction(landhold1);
27764 }
27765
27766
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3 times.
14 if(ptr->twohand)
27767 {
27768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(action==waterhold1)
27769 {
27770 action=waterhold2; FFCore.setHeroAction(waterhold2);
27771 }
27772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(action==sidewaterhold1)
27773 {
27774 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
27775 }
27776 else
27777 {
27778 3 action=landhold2; FFCore.setHeroAction(landhold2);
27779 }
27780 3 }
27781
27782 14 holdclk=130;
27783
27784 //restart music
27785
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0)
27786 5 music_stop();
27787
27788 14 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
27789 14 freeze_guys=true;
27790 //show the info string
27791
27792
27793 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
27794
27795 14 int32_t shop_pstr = 0;
27796
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 if (PriceIndex > -1)
27797 {
27798
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 switch(tmpscr[tmp].room)
27799 {
27800 case rSHOP:
27801 1 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
27802 1 break;
27803 case rBOTTLESHOP:
27804 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
27805 break;
27806 }
27807 1 }
27808
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27809 {
27810 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
27811 {
27812 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27813 }
27814 else pstr = 0;
27815 if(shop_pstr)
27816 {
27817 donewmsg(shop_pstr);
27818 enqueued_str = pstr;
27819 }
27820 else if(pstr)
27821 {
27822 donewmsg(pstr);
27823 }
27824 }
27825
27826 14 }
27827
27828
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
14 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
27829 {
27830 12 sfx(tmpscr[0].holdupsfx);
27831 12 }
27832
27833 14 ptr->set_forcegrab(false);
27834 14 items.del(index);
27835
27836
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 14 times.
16 for(int32_t i=0; i<Lwpns.Count(); i++)
27837 {
27838 2 weapon *w = (weapon*)Lwpns.spr(i);
27839
27840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(w->dragging==index)
27841 {
27842 w->dragging=-1;
27843 }
27844
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(w->dragging>index)
27845 {
27846 w->dragging-=1;
27847 }
27848 2 }
27849
27850 // clear up shop stuff
27851
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1 times.
14 if((isdungeon()==0)&&(index!=0))
27852 {
27853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(boughtsomething)
27854 {
27855 1 fadeclk=66;
27856
27857
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
27858 {
27859 1 items.del(0);
27860
27861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 for(int32_t i=0; i<Lwpns.Count(); i++)
27862 {
27863 weapon *w = (weapon*)Lwpns.spr(i);
27864
27865 if(w->dragging==0)
27866 {
27867 w->dragging=-1;
27868 }
27869 else if(w->dragging>0)
27870 {
27871 w->dragging-=1;
27872 }
27873 }
27874 1 }
27875 1 }
27876
27877
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(msg_onscreen)
27878 {
27879 dismissmsg();
27880 }
27881
27882 1 clear_bitmap(pricesdisplaybuf);
27883 1 set_clip_state(pricesdisplaybuf, 1);
27884 1 }
27885
27886 // items.del(index);
27887 14 }
27888 else
27889 {
27890 88 ptr->set_forcegrab(false);
27891 88 items.del(index);
27892
27893
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 88 times.
118 for(int32_t i=0; i<Lwpns.Count(); i++)
27894 {
27895 30 weapon *w = (weapon*)Lwpns.spr(i);
27896
27897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(w->dragging==index)
27898 {
27899 w->dragging=-1;
27900 }
27901
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 else if(w->dragging>index)
27902 {
27903 w->dragging-=1;
27904 }
27905 30 }
27906
27907
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(msg_onscreen)
27908 {
27909 dismissmsg();
27910 }
27911
27912 //general item pickup message
27913 //show the info string
27914 //non-held
27915 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
27916
3/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 87 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
88 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
27917
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 87 times.
88 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27918 {
27919
6/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
1 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
27920 {
27921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27922 1 }
27923 else pstr = 0;
27924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(shop_pstr)
27925 {
27926 donewmsg(shop_pstr);
27927 enqueued_str = pstr;
27928 }
27929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(pstr)
27930 {
27931 1 donewmsg(pstr);
27932 1 }
27933 1 }
27934
27935
27936 88 clear_bitmap(pricesdisplaybuf);
27937 88 set_clip_state(pricesdisplaybuf, 1);
27938 }
27939
27940
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 2 times.
102 if(itemsbuf[id2].family==itype_triforcepiece)
27941 {
27942
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[id2].misc2>0) //Small TF Piece
27943 {
27944 2 getTriforce(id2);
27945 2 }
27946 else
27947 {
27948 if (ptr->linked_parent == eeGANON) game->lvlitems[dlevel]|=liBOSS;
27949 getBigTri(id2);
27950 }
27951 2 }
27952 79850 }
27953
27954 3 void HeroClass::StartRefill(int32_t refillWhat)
27955 {
27956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!refilling)
27957 {
27958 3 refillclk=21;
27959 3 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27960 3 sfx(WAV_REFILL,128,true);
27961 3 refilling=refillWhat;
27962
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(FFCore.quest_format[vZelda] < 0x255)
27963 {
27964 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
27965 //I attempted to change this check to a quest rule, but here's the issue: this affects
27966 //triforces and potions as well, not just fairy flags. This means that having a compat rule
27967 //would result in a rule that is checked by default for every tileset or quest made before
27968 //2.55, one in a place most people won't check. That means that if they were to go to use
27969 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
27970 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
27971 //"go through the compat rules and turn them all off", so this remains a version check instead
27972 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
27973 3 Start250Refill(refillWhat);
27974 3 }
27975 else //use 2.55+ behavior
27976 {
27977 if(refill_why>=0) // Item index
27978 {
27979 if(itemsbuf[refill_why].family==itype_potion)
27980 {
27981 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27982 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27983 }
27984 else if(itemsbuf[refill_why].family==itype_triforcepiece)
27985 {
27986 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27987 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27988 }
27989 }
27990 else if(refill_why==REFILL_FAIRY)
27991 {
27992 if(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
27993 if(get_bit(quest_rules,qr_ITEMBUBBLE))itemclk=0;
27994 }
27995 }
27996 3 }
27997 3 }
27998
27999 3 void HeroClass::Start250Refill(int32_t refillWhat)
28000 {
28001
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!refilling)
28002 {
28003 refillclk=21;
28004 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
28005 sfx(WAV_REFILL,128,true);
28006 refilling=refillWhat;
28007
28008 if(refill_why>=0) // Item index
28009 {
28010 if((itemsbuf[refill_why].family==itype_potion)&&(!get_bit(quest_rules,qr_NONBUBBLEMEDICINE)))
28011 {
28012 swordclk=0;
28013 verifyAWpn();
28014 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
28015 }
28016
28017 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_bit(quest_rules,qr_NONBUBBLETRIFORCE)))
28018 {
28019 swordclk=0;
28020 verifyAWpn();
28021 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
28022 }
28023 }
28024 else if((refill_why==REFILL_FAIRY)&&(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)))
28025 {
28026 swordclk=0;
28027 verifyAWpn();
28028 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
28029 }
28030 }
28031 3 }
28032
28033 419 bool HeroClass::refill()
28034 {
28035
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
419 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
28036 {
28037 412 return false;
28038 }
28039
28040 7 ++refillclk;
28041 7 int32_t speed = get_bit(quest_rules,qr_FASTFILL) ? 6 : 22;
28042 7 int32_t refill_heart_stop=game->get_maxlife();
28043 7 int32_t refill_magic_stop=game->get_maxmagic();
28044
28045
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
7 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
28046 {
28047 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
28048 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
28049 }
28050
28051
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(refillclk%speed == 0)
28052 {
28053 // game->life&=0xFFC;
28054
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
3 switch(refill_what)
28055 {
28056 case REFILL_LIFE:
28057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28058
28059
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(game->get_life()>=refill_heart_stop)
28060 {
28061 1 game->set_life(refill_heart_stop);
28062 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28063
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28064 {
28065
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 255 times.
256 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28067 255 stop_sfx(q);
28068 255 }
28069 1 sfx(QMisc.miscsfx[sfxREFILL]);
28070 1 refilling=REFILL_NONE;
28071 1 return false;
28072 }
28073
28074 break;
28075
28076 case REFILL_MAGIC:
28077 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28078
28079 if(game->get_magic()>=refill_magic_stop)
28080 {
28081 game->set_magic(refill_magic_stop);
28082 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28083 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28084 {
28085 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28086 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28087 stop_sfx(q);
28088 }
28089 sfx(QMisc.miscsfx[sfxREFILL]);
28090 refilling=REFILL_NONE;
28091 return false;
28092 }
28093
28094 break;
28095
28096 case REFILL_ALL:
28097
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28098
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28099
28100
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
28101 {
28102 2 game->set_life(refill_heart_stop);
28103 2 game->set_magic(refill_magic_stop);
28104 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28105
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28106 {
28107
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 510 times.
512 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28108
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 509 times.
510 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28109 509 stop_sfx(q);
28110 509 }
28111 2 sfx(QMisc.miscsfx[sfxREFILL]);
28112 2 refilling=REFILL_NONE;
28113 2 return false;
28114 }
28115
28116 break;
28117 }
28118 }
28119
28120 4 return true;
28121 419 }
28122
28123 2 void HeroClass::getTriforce(int32_t id2)
28124 {
28125
28126 PALETTE flash_pal;
28127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
28128
28129
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t i=0; i<256; i++)
28130 {
28131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
28132 512 }
28133
28134
28135
28136 //get rid off all sprites but Hero
28137 2 guys.clear();
28138 2 items.clear();
28139 2 Ewpns.clear();
28140 2 Lwpns.clear();
28141 2 Sitems.clear();
28142 2 chainlinks.clear();
28143
28144 //decorations.clear();
28145
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(!COOLSCROLL)
28146 {
28147 1 show_subscreen_items=false;
28148 1 }
28149
28150 2 sfx(itemsbuf[id2].playsound);
28151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
28152
28153 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
28154
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
28155 {
28156 uint8_t playwav = itemsbuf[id2].misc3;
28157 //zprint2("playwav is: %d\n", playwav);
28158 sfx(playwav);
28159
28160 }
28161
28162 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
28163 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
28164 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
28165 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
28166 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
28167 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
28168 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
28169
28170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
28171 {
28172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[id2].misc1)
28173 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
28174 else
28175 2 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
28176 2 }
28177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28178 {
28179 2 game->lvlitems[dlevel]|=liTRIFORCE;
28180 2 }
28181
28182 2 int32_t f=0;
28183 2 int32_t x2=0;
28184 2 int32_t curtain_x=0;
28185 2 int32_t c=0;
28186 /*if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //Run collect script This happens w/o the flag.
28187 {
28188 if(itemsbuf[id2].collect_script && !item_collect_doscript[id2])
28189 {
28190 //clear the item script stack for a new script
28191 ri = &(itemCollectScriptData[id2]);
28192 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id2][q] = 0xFFFF;
28193 ri->Clear();
28194 //itemCollectScriptData[(id2 & 0xFFF)].Clear();
28195 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[(id2 & 0xFFF)][q] = 0;
28196 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2 & 0xFFF)*-1));
28197 if ( id2 > 0 && !item_collect_doscript[id2] ) //No collect script on item 0.
28198 {
28199 item_collect_doscript[id2] = 1;
28200 itemscriptInitialised[id2] = 0;
28201 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2)*-1));
28202 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28203 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id2));
28204 }
28205 else if (!id2 && !item_collect_doscript[id2]) //item 0
28206 {
28207 item_collect_doscript[id2] = 1;
28208 itemscriptInitialised[id2] = 0;
28209 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
28210 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28211 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
28212 }
28213 }
28214 }
28215 */
28216 2 do
28217 {
28218
28219
28220
1/2
✓ Branch 0 taken 961 times.
✗ Branch 1 not taken.
961 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
28221 {
28222 if ( itemsbuf[id2].script )
28223 {
28224 if ( !item_doscript[id2] )
28225 {
28226 ri = &(itemScriptData[id2]);
28227 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id2][q] = 0xFFFF;
28228 ri->Clear();
28229 item_doscript[id2] = 1;
28230 itemscriptInitialised[id2] = 0;
28231 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2);
28232 FFCore.deallocateAllArrays(SCRIPT_ITEM,(id2));
28233 }
28234 else
28235 {
28236 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
28237 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
28238 }
28239 }
28240 }
28241 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
28242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 961 times.
961 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
28243 {
28244 return;
28245 }
28246
2/2
✓ Branch 0 taken 959 times.
✓ Branch 1 taken 2 times.
961 if(f==40)
28247 {
28248 2 actiontype oldaction = action;
28249 2 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
28250 2 action=oldaction; // have to reset this flag
28251 2 FFCore.setHeroAction(oldaction);
28252 2 }
28253
28254
28255
4/4
✓ Branch 0 taken 881 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 785 times.
✓ Branch 3 taken 96 times.
961 if(f>=40 && f<88)
28256 {
28257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(get_bit(quest_rules,qr_FADE))
28258 {
28259 //int32_t flashbit = ;
28260 if((f&(((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)) ? 6 : 3))==0)
28261 {
28262 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
28263 refreshpal=true;
28264 }
28265
28266 if((f&3)==2)
28267 {
28268 loadpalset(0,0);
28269 loadpalset(1,1);
28270 loadpalset(5,5);
28271
28272 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28273 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
28274 }
28275 }
28276 else
28277 {
28278
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 12 times.
96 if((f&((get_bit(quest_rules,qr_EPILEPSY)) ? 10 : 7))==0)
28279 {
28280
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
48 for(int32_t cs2=2; cs2<5; cs2++)
28281 {
28282
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 36 times.
576 for(int32_t i=1; i<16; i++)
28283 {
28284 540 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
28285 540 }
28286 36 }
28287
28288 12 refreshpal=true;
28289 12 }
28290
28291
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 12 times.
96 if((f&7)==4)
28292 {
28293
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28294 else loadlvlpal(0xB);
28295
28296 12 loadpalset(5,5);
28297 12 }
28298 }
28299 96 }
28300
28301
28302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 961 times.
961 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28303 {
28304
2/2
✓ Branch 0 taken 959 times.
✓ Branch 1 taken 2 times.
961 if(f==refill_frame)
28305 {
28306 2 refill_what=REFILL_ALL;
28307 2 refill_why=id2;
28308 2 StartRefill(REFILL_ALL);
28309 2 refill();
28310 2 }
28311
28312
2/2
✓ Branch 0 taken 958 times.
✓ Branch 1 taken 3 times.
961 if(f==(refill_frame+1))
28313 {
28314
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(refill())
28315 {
28316 1 --f;
28317 1 }
28318 3 }
28319 961 }
28320
28321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 961 times.
961 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
28322 {
28323
4/4
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 417 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 160 times.
961 if(f>=208 && f<288)
28324 {
28325 160 ++x2;
28326
28327
3/3
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 32 times.
160 switch(++c)
28328 {
28329 case 5:
28330 32 c=0;
28331 [[fallthrough]];
28332 case 0:
28333 case 2:
28334 case 3:
28335 96 ++x2;
28336 96 break;
28337 }
28338 160 }
28339
28340 961 do_dcounters();
28341
28342
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 577 times.
961 if(f<288)
28343 {
28344 577 curtain_x=x2&0xF8;
28345 577 draw_screen_clip_rect_x1=curtain_x;
28346 577 draw_screen_clip_rect_x2=255-curtain_x;
28347 577 draw_screen_clip_rect_y1=0;
28348 577 draw_screen_clip_rect_y2=223;
28349 //draw_screen(tmpscr);
28350 577 }
28351 961 }
28352
28353 961 draw_screen(tmpscr);
28354 //this causes bugs
28355 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
28356 //so this is not necessary -DD
28357 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,false);
28358
28359 //Run Triforce Script
28360 961 advanceframe(true);
28361 961 ++f;
28362
2/2
✓ Branch 0 taken 959 times.
✓ Branch 1 taken 2 times.
1922 }
28363 while
28364 (
28365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 961 times.
961 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
28366
4/6
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
961 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
28367
3/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 146 times.
✗ Branch 7 not taken.
292 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
28368 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
28369 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
28370 // value doesn't matter.
28371
2/4
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 146 times.
146 || (replay_is_active() && f < 480) )
28372 ); // 800 may not be just right, but it works
28373
28374 2 action=none; FFCore.setHeroAction(none);
28375 2 holdclk=0;
28376 2 draw_screen_clip_rect_x1=0;
28377 2 draw_screen_clip_rect_x2=255;
28378 2 draw_screen_clip_rect_y1=0;
28379 2 draw_screen_clip_rect_y2=223;
28380 2 show_subscreen_items=true;
28381
28382 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
28383 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
28384
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(itemsbuf[id2].flags & ITEM_FLAG1 && ( get_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
28385 {
28386 2 sdir=dir;
28387 2 dowarp(1,0); //side warp
28388 2 }
28389 else
28390 {
28391 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
28392 }
28393 2 }
28394
28395 void red_shift()
28396 {
28397 int32_t tnum=176;
28398
28399 // set up the new palette
28400 for(int32_t i=CSET(2); i < CSET(4); i++)
28401 {
28402 int32_t r = (i-CSET(2)) << 1;
28403 RAMpal[i+tnum].r = r;
28404 RAMpal[i+tnum].g = r >> 3;
28405 RAMpal[i+tnum].b = r >> 4;
28406 }
28407
28408 // color scale the game screen
28409 for(int32_t y=0; y<168; y++)
28410 {
28411 for(int32_t x=0; x<256; x++)
28412 {
28413 int32_t c = framebuf->line[y+playing_field_offset][x];
28414 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28415 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
28416 }
28417 }
28418
28419 refreshpal = true;
28420 }
28421
28422
28423
28424 void setup_red_screen_old()
28425 {
28426 clear_bitmap(framebuf);
28427 rectfill(scrollbuf, 0, 0, 255, 167, 0);
28428
28429 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
28430
28431 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
28432
28433 putscr(scrollbuf, 0, 0, tmpscr);
28434 putscrdoors(scrollbuf,0,0,tmpscr);
28435 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28436 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
28437
28438 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
28439
28440 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
28441 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
28442 {
28443 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
28444 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
28445 }
28446
28447 if(!(msg_bg_display_buf->clip))
28448 {
28449 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28450 }
28451
28452 if(!(msg_portrait_display_buf->clip))
28453 {
28454 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28455 }
28456
28457 if(!(msg_txt_display_buf->clip))
28458 {
28459 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28460 }
28461
28462 if(!(pricesdisplaybuf->clip))
28463 {
28464 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
28465 }
28466
28467 //red shift
28468 // color scale the game screen
28469 for(int32_t y=0; y<168; y++)
28470 {
28471 for(int32_t x=0; x<256; x++)
28472 {
28473 int32_t c = framebuf->line[y+playing_field_offset][x];
28474 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28475 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
28476 }
28477 }
28478
28479 // Hero->draw(framebuf);
28480 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
28481
28482 clear_bitmap(framebuf);
28483
28484 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
28485 && tmpscr->layermap[3]==0
28486 && tmpscr->layermap[4]==0
28487 && tmpscr->layermap[5]==0
28488 && !overheadcombos(tmpscr)))
28489 {
28490 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
28491
28492 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
28493 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
28494 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
28495 {
28496 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
28497 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
28498 }
28499 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
28500 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
28501
28502 //do an AND masked blit for messages on top of layers
28503 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
28504 {
28505 BITMAP* subbmp = create_bitmap_ex(8,256,168);
28506 clear_bitmap(subbmp);
28507 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
28508 {
28509 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
28510 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
28511 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
28512 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
28513 }
28514 for(int32_t y=0; y<168; y++)
28515 {
28516 for(int32_t x=0; x<256; x++)
28517 {
28518 int32_t c1 = framebuf->line[y+playing_field_offset][x];
28519 int32_t c2 = subbmp->line[y][x];
28520 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
28521
28522 if(c1 && c3)
28523 {
28524 framebuf->line[y+playing_field_offset][x] = c3;
28525 }
28526 else if(c1 && c2)
28527 {
28528 framebuf->line[y+playing_field_offset][x] = c2;
28529 }
28530 }
28531 }
28532 destroy_bitmap(subbmp);
28533 }
28534
28535 //red shift
28536 // color scale the game screen
28537 for(int32_t y=0; y<168; y++)
28538 {
28539 for(int32_t x=0; x<256; x++)
28540 {
28541 int32_t c = framebuf->line[y+playing_field_offset][x];
28542 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28543 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
28544 }
28545 }
28546 }
28547
28548 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
28549
28550 // set up the new palette
28551 for(int32_t i=CSET(2); i < CSET(4); i++)
28552 {
28553 int32_t r = (i-CSET(2)) << 1;
28554 RAMpal[i].r = r;
28555 RAMpal[i].g = r >> 3;
28556 RAMpal[i].b = r >> 4;
28557 }
28558
28559 refreshpal = true;
28560 }
28561
28562
28563
28564 void slide_in_color(int32_t color)
28565 {
28566 for(int32_t i=1; i<16; i+=3)
28567 {
28568 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
28569 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
28570 RAMpal[CSET(2)+i] = NESpal(color);
28571 }
28572
28573 refreshpal=true;
28574 }
28575
28576
28577 void HeroClass::heroDeathAnimation()
28578 {
28579 int32_t f=0;
28580 int32_t deathclk=0,deathfrm=0;
28581
28582 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
28583
28584 kill_sfx(); //call before the onDeath script.
28585
28586 //do
28587 //{
28588
28589 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28590 // FFCore.Waitframe();
28591 //}while(player_doscript);
28592 //ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28593 //while(player_doscript) { advanceframe(true); } //Not safe. The script runs for only one frame at present.
28594
28595 //Playing=false;
28596 if(!debug_enabled)
28597 {
28598 Paused=false;
28599 }
28600
28601 /*
28602 game->set_deaths(zc_min(game->get_deaths()+1,999));
28603 dir=down;
28604 music_stop();
28605
28606 attackclk=hclk=superman=0;
28607 scriptcoldet = 1;
28608
28609 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28610
28611
28612
28613 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28614 quakeclk=wavy=0;
28615
28616 //in original Z1, Hero marker vanishes at death.
28617 //code in subscr.cpp, put_passive_subscr checks the following value.
28618 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28619 //Also, subscreen is static after death in Z1.
28620 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28621 QMisc.colors.hero_dot = 255;
28622 //doesn't work
28623 //scrollbuf is tampered with by draw_screen()
28624 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28625 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28626 clear_bitmap(subscrbmp);
28627 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, false, sspUP);
28628 QMisc.colors.hero_dot = tmp_hero_dot;
28629 */
28630 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28631 clear_bitmap(subscrbmp);
28632 //get rid off all sprites but Hero
28633 guys.clear();
28634 items.clear();
28635 Ewpns.clear();
28636 Lwpns.clear();
28637 Sitems.clear();
28638 chainlinks.clear();
28639 decorations.clear();
28640 Playing = false;
28641
28642 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
28643 dir=down;
28644 music_stop();
28645
28646 attackclk=hclk=superman=0;
28647 scriptcoldet = 1;
28648
28649 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28650
28651
28652
28653 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28654 quakeclk=wavy=0;
28655
28656 //in original Z1, Hero marker vanishes at death.
28657 //code in subscr.cpp, put_passive_subscr checks the following value.
28658 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28659 //Also, subscreen is static after death in Z1.
28660 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28661 QMisc.colors.hero_dot = 255;
28662 //doesn't work
28663 //scrollbuf is tampered with by draw_screen()
28664 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28665
28666 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
28667 //Don't forget passive subscreen scripts!
28668 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
28669 {
28670 script_drawing_commands.Clear(); //We only want draws from this script
28671 if(DMaps[currdmap].passive_sub_script != 0)
28672 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28673 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
28674 {
28675 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28676 passive_subscreen_waitdraw = false;
28677 }
28678 BITMAP* tmp = framebuf;
28679 framebuf = subscrbmp; //Hack; force draws to subscrbmp
28680 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
28681 framebuf = tmp;
28682 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
28683 }
28684 QMisc.colors.hero_dot = tmp_hero_dot;
28685 bool clearedit = false;
28686 do
28687 {
28688 //if ( player_doscript )
28689 //{
28690 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_WIN, SCRIPT_PLAYER_WIN);
28691 //if ( f ) --f;
28692 // load_control_state(); //goto adv;
28693 //}
28694 //else
28695 //{
28696 // if ( !clearedit )
28697 // {
28698
28699
28700 // clearedit = true;
28701
28702 // }
28703 //}
28704 //else Playing = false;
28705 if(f<254)
28706 {
28707 if(f<=32)
28708 {
28709 hclk=(32-f);
28710 }
28711
28712 if(f>=62 && f<138)
28713 {
28714 switch((f-62)%20)
28715 {
28716 case 0:
28717 dir=right;
28718 break;
28719
28720 case 5:
28721 dir=up;
28722 break;
28723
28724 case 10:
28725 dir=left;
28726 break;
28727
28728 case 15:
28729 dir=down;
28730 break;
28731 }
28732
28733 herostep();
28734 }
28735
28736 if(f>=194 && f<208)
28737 {
28738 if(f==194)
28739 {
28740 action=dying;
28741 FFCore.setHeroAction(dying);
28742 }
28743
28744 extend = 0;
28745 cs = wpnsbuf[spr_death].csets&15;
28746 tile = wpnsbuf[spr_death].tile;
28747 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
28748 {
28749 tile += deathfrm;
28750 f = 206;
28751 if(++deathclk >= wpnsbuf[spr_death].speed)
28752 {
28753 deathclk=0;
28754 if(++deathfrm >= wpnsbuf[spr_death].frames)
28755 {
28756 f = 208;
28757 deathfrm = 0;
28758 }
28759 }
28760 }
28761 else if(BSZ)
28762 {
28763 tile += (f-194)/3;
28764 }
28765 else if(f>=204)
28766 {
28767 ++tile;
28768 }
28769 }
28770
28771 if(f==208)
28772 {
28773 if ( dontdraw < 2 ) { dontdraw = 1; }
28774 }
28775 if(get_bit(quest_rules,qr_FADE))
28776 {
28777 if(f < 170)
28778 {
28779 if(f<60)
28780 {
28781 draw_screen(tmpscr);
28782 //reuse our static subscreen
28783 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
28784 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28785 }
28786
28787 if(f==60)
28788 {
28789 red_shift();
28790 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28791 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28792 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28793
28794 for(int32_t q=0; q<PAL_SIZE; q++)
28795 {
28796 trans_table2.data[0][q] = q;
28797 trans_table2.data[q][q] = q;
28798 }
28799 }
28800
28801 if(f>=60 && f<=169)
28802 {
28803 draw_screen(tmpscr);
28804 //reuse our static subscreen
28805 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28806 red_shift();
28807
28808 }
28809
28810 if(f>=139 && f<=169)//fade from red to black
28811 {
28812 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
28813 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28814 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28815 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28816
28817 for(int32_t q=0; q<PAL_SIZE; q++)
28818 {
28819 trans_table2.data[0][q] = q;
28820 trans_table2.data[q][q] = q;
28821 }
28822
28823 refreshpal=true;
28824 }
28825 }
28826 else //f>=170
28827 {
28828 if(f==170)//make Hero grayish
28829 {
28830 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
28831
28832 for(int32_t i=CSET(6); i < CSET(7); i++)
28833 {
28834 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
28835 RAMpal[i] = _RGB(g,g,g);
28836 }
28837
28838 refreshpal = true;
28839 }
28840
28841 //draw only hero. otherwise black layers might cover him.
28842 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28843 draw(framebuf);
28844 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28845 }
28846 }
28847 else //!qr_FADE
28848 {
28849 if(f==58)
28850 {
28851 for(int32_t i = 0; i < 96; i++)
28852 tmpscr->cset[i] = 3;
28853
28854 for(int32_t j=0; j<6; j++)
28855 if(tmpscr->layermap[j]>0)
28856 for(int32_t i=0; i<96; i++)
28857 tmpscr2[j].cset[i] = 3;
28858 }
28859
28860 if(f==59)
28861 {
28862 for(int32_t i = 96; i < 176; i++)
28863 tmpscr->cset[i] = 3;
28864
28865 for(int32_t j=0; j<6; j++)
28866 if(tmpscr->layermap[j]>0)
28867 for(int32_t i=96; i<176; i++)
28868 tmpscr2[j].cset[i] = 3;
28869 }
28870
28871 if(f==60)
28872 {
28873 for(int32_t i=0; i<176; i++)
28874 {
28875 tmpscr->cset[i] = 2;
28876 }
28877
28878 for(int32_t j=0; j<6; j++)
28879 if(tmpscr->layermap[j]>0)
28880 for(int32_t i=0; i<176; i++)
28881 tmpscr2[j].cset[i] = 2;
28882
28883 for(int32_t i=1; i<16; i+=3)
28884 {
28885 RAMpal[CSET(2)+i] = NESpal(0x17);
28886 RAMpal[CSET(2)+i+1] = NESpal(0x16);
28887 RAMpal[CSET(2)+i+2] = NESpal(0x26);
28888 }
28889
28890 refreshpal=true;
28891 }
28892
28893 if(f==139)
28894 slide_in_color(0x06);
28895
28896 if(f==149)
28897 slide_in_color(0x07);
28898
28899 if(f==159)
28900 slide_in_color(0x0F);
28901
28902 if(f==169)
28903 {
28904 slide_in_color(0x0F);
28905 slide_in_color(0x0F);
28906 }
28907
28908 if(f==170)
28909 {
28910 for(int32_t i=1; i<16; i+=3)
28911 {
28912 RAMpal[CSET(6)+i] = NESpal(0x10);
28913 RAMpal[CSET(6)+i+1] = NESpal(0x30);
28914 RAMpal[CSET(6)+i+2] = NESpal(0x00);
28915 refreshpal = true;
28916 }
28917 }
28918
28919 if(f < 169)
28920 {
28921 draw_screen(tmpscr);
28922 //reuse our static subscreen
28923 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28924 }
28925 else
28926 {
28927 //draw only hero. otherwise black layers might cover him.
28928 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28929 draw(framebuf);
28930 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28931 }
28932 }
28933 }
28934
28935 else if(f<350)//draw 'GAME OVER' text
28936 {
28937 if(get_bit(quest_rules, qr_INSTANT_RESPAWN) && !get_bit(quest_rules, qr_INSTANT_CONTINUE))
28938 {
28939 Quit = qRELOAD;
28940 skipcont = 1;
28941 clear_bitmap(framebuf);
28942 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28943 }
28944 else if(!get_bit(quest_rules, qr_INSTANT_RESPAWN) && get_bit(quest_rules, qr_INSTANT_CONTINUE))
28945 {
28946 Quit = qCONT;
28947 skipcont = 1;
28948 clear_bitmap(framebuf);
28949 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28950 }
28951 else
28952 {
28953 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
28954 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28955 textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
28956 }
28957 }
28958 else
28959 {
28960 clear_bitmap(framebuf);
28961 }
28962
28963 //SFX... put them all here
28964 switch(f)
28965 {
28966 case 0:
28967 sfx(getHurtSFX(),pan(x.getInt()));
28968 break;
28969 //Death sound.
28970 case 60:
28971 sfx(WAV_SPIRAL);
28972 break;
28973 //Message sound.
28974 case 194:
28975 sfx(WAV_MSG);
28976 break;
28977 }
28978 //adv:
28979 advanceframe(true);
28980 ++f;
28981 //if (!player_doscript ) ++f;
28982 }
28983 while(f<353 && !Quit);
28984
28985 destroy_bitmap(subscrbmp);
28986 action=none; FFCore.setHeroAction(none);
28987 if ( dontdraw < 2 ) { dontdraw=0; }
28988 }
28989
28990
28991 void HeroClass::ganon_intro()
28992 {
28993 /*
28994 ************************
28995 * GANON INTRO SEQUENCE *
28996 ************************
28997 -25 DOT updates
28998 -24 HERO in
28999 0 TRIFORCE overhead - code begins at this point (f == 0)
29000 47 GANON in
29001 58 LIGHT step
29002 68 LIGHT step
29003 78 LIGHT step
29004 255 TRIFORCE out
29005 256 TRIFORCE in
29006 270 TRIFORCE out
29007 271 GANON out, HERO face up
29008 */
29009 loaded_guys=true;
29010 loaditem();
29011
29012 if(game->lvlitems[dlevel]&liBOSS)
29013 {
29014 return;
29015 }
29016
29017 dir=down;
29018 if ( !isSideViewHero() )
29019 {
29020 fall = 0; //Fix midair glitch on holding triforce. -Z
29021 fakefall = 0;
29022 z = 0;
29023 fakez = 0;
29024 }
29025 action=landhold2; FFCore.setHeroAction(landhold2);
29026 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
29027 //not good, as this only returns the highest level that Hero possesses. -DD
29028 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
29029
29030 for(int32_t f=0; f<271 && !Quit; f++)
29031 {
29032 if(f==47)
29033 {
29034 music_stop();
29035 stop_sfx(WAV_ROAR);
29036 sfx(WAV_GASP);
29037 sfx(WAV_GANON);
29038 int32_t Id=0;
29039
29040 for(int32_t i=0; i<eMAXGUYS; i++)
29041 {
29042 if(guysbuf[i].flags2&eneflag_ganon)
29043 {
29044 Id=i;
29045 break;
29046 }
29047 }
29048
29049 if(current_item(itype_ring))
29050 {
29051 addenemy(160,96,Id,0);
29052 }
29053 else
29054 {
29055 addenemy(80,32,Id,0);
29056 }
29057 }
29058
29059 if(f==48)
29060 {
29061 lighting(true,true); // Hmm. -L
29062 f += 30;
29063 }
29064
29065 //NES Z1, the triforce vanishes for one frame in two cases
29066 //while still showing Hero's two-handed overhead sprite.
29067 //This should be a Quest Rule for NES Accuracy. -Z
29068 if(f==255 || f==270)
29069 {
29070 holditem=-1;
29071 }
29072
29073 if(f==256)
29074 {
29075 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
29076 }
29077
29078 draw_screen(tmpscr);
29079 advanceframe(true);
29080
29081 if(rSbtn())
29082 {
29083 conveyclk=3;
29084 int32_t tmp_subscr_clk = frame;
29085 dosubscr(&QMisc);
29086 newscr_clk += frame - tmp_subscr_clk;
29087 }
29088
29089 }
29090
29091 action=none; FFCore.setHeroAction(none);
29092 dir=up;
29093
29094 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
29095 jukebox(MAXMIDIS-1);
29096 else
29097 playLevelMusic();
29098
29099 currcset=DMaps[currdmap].color;
29100 if (get_bit(quest_rules, qr_GANONINTRO) )
29101 {
29102 dointro();
29103 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
29104 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
29105 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
29106 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
29107 }
29108 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
29109 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
29110 //on a different DMap.
29111 //~ Otherwise, why is it here?! -Z
29112
29113
29114 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
29115 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
29116
29117 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
29118 //Users who use that dmap rule should put ganons room on its own DMap! -Z
29119 cont_sfx(WAV_ROAR);
29120 }
29121
29122 void HeroClass::win_game()
29123 {
29124 replay_step_comment("win_game");
29125 Playing=Paused=false;
29126 action=won; FFCore.setHeroAction(won);
29127 Quit=qWON;
29128 hclk=0;
29129 x = 136;
29130 y = (isdungeon() && currscr<128) ? 75 : 73;
29131 z = fakez = fall = fakefall = spins = 0;
29132 dir=left;
29133 }
29134
29135 237 void HeroClass::reset_swordcharge()
29136 {
29137 237 charging=spins=tapping=0;
29138 237 }
29139
29140 268 void HeroClass::reset_hookshot()
29141 {
29142
7/12
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 214 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 214 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 214 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 214 times.
268 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
29143 {
29144 214 action=none; FFCore.setHeroAction(none);
29145 214 }
29146
29147 268 hookshot_frozen=false;
29148 268 hookshot_used=false;
29149 268 pull_hero=false;
29150 268 hs_fix=false;
29151 268 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
29152 268 switch_hooked = false;
29153
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if(switching_object)
29154 switching_object->switch_hooked = false;
29155 268 switching_object = NULL;
29156 268 hooked_combopos = -1;
29157 268 switchhook_cost_item = -1;
29158 268 hooked_layerbits = 0;
29159
2/2
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 268 times.
2144 for(auto q = 0; q < 7; ++q)
29160 1876 hooked_undercombos[q] = -1;
29161 268 Lwpns.del(Lwpns.idFirst(wHSHandle));
29162 268 Lwpns.del(Lwpns.idFirst(wHookshot));
29163 268 chainlinks.clear();
29164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
268 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
29165 268 hs_switcher = false;
29166
29167
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 1 times.
268 if(index>=0)
29168 {
29169 1 stop_sfx(itemsbuf[index].usesound);
29170 1 }
29171
29172 268 hs_xdist=0;
29173 268 hs_ydist=0;
29174 268 }
29175
29176
29177 55297 bool HeroClass::can_deploy_ladder()
29178 {
29179
2/2
✓ Branch 0 taken 8933 times.
✓ Branch 1 taken 46364 times.
94613 bool ladderallowed = ((!get_bit(quest_rules,qr_LADDERANYWHERE) && tmpscr->flags&fLADDER) || isdungeon()
29180
4/4
✓ Branch 0 taken 7048 times.
✓ Branch 1 taken 39316 times.
✓ Branch 2 taken 2663 times.
✓ Branch 3 taken 36653 times.
46364 || (get_bit(quest_rules,qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
29181
7/10
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 54269 times.
✓ Branch 2 taken 1028 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1027 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1027 times.
56324 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
29182
1/2
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
1027 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
29183 }
29184
29185 65209 void HeroClass::reset_ladder()
29186 {
29187 65209 ladderx=laddery=0;
29188 65209 }
29189
29190 bool is_conveyor(int32_t type);
29191 int32_t get_conveyor(int32_t x, int32_t y);
29192
29193 79959 void HeroClass::check_conveyor()
29194 {
29195 79959 ++newconveyorclk;
29196
1/2
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
79959 if (newconveyorclk < 0) newconveyorclk = 0;
29197
29198
10/18
✓ Branch 0 taken 79959 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79959 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 79831 times.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 79831 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 79831 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 79831 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 79831 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 79831 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 79831 times.
✗ Branch 17 not taken.
79959 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
29199 {
29200 128 is_conveyor_stunned = 0;
29201 128 return;
29202 }
29203
29204 79831 WalkflagInfo info;
29205 int32_t xoff,yoff;
29206 79831 zfix deltax(0), deltay(0);
29207 79831 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
29208
2/2
✓ Branch 0 taken 52954 times.
✓ Branch 1 taken 26877 times.
79831 if(cmbid < 0)
29209 {
29210
2/2
✓ Branch 0 taken 52712 times.
✓ Branch 1 taken 242 times.
52954 if (conveyclk <= 0) is_on_conveyor=false;
29211 52954 return;
29212 }
29213 26877 newcombo const* cmb = &combobuf[cmbid];
29214 26877 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
29215 26877 bool custom_spd = (cmb->usrflags&cflag2);
29216
3/4
✓ Branch 0 taken 26049 times.
✓ Branch 1 taken 828 times.
✓ Branch 2 taken 26049 times.
✗ Branch 3 not taken.
26877 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
29217 {
29218 26877 int32_t ctype=cmb->type;
29219
3/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 26049 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 828 times.
26877 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
29220
3/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 26049 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 828 times.
26877 if(custom_spd && (newconveyorclk % rate)) return;
29221
3/4
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 26202 times.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
26877 if((cmb->usrflags&cflag5) && HasHeavyBoots())
29222 return;
29223 26877 is_on_conveyor=false;
29224 26877 is_conveyor_stunned=0;
29225
29226 26877 deltax=combo_class_buf[ctype].conveyor_x_speed;
29227 26877 deltay=combo_class_buf[ctype].conveyor_y_speed;
29228
29229
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26877 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26877 if (is_conveyor(ctype) && custom_spd)
29230 {
29231 deltax = zslongToFix(cmb->attributes[0]);
29232 deltay = zslongToFix(cmb->attributes[1]);
29233 }
29234
29235
6/8
✓ Branch 0 taken 26877 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26877 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2868 times.
✓ Branch 5 taken 24009 times.
✓ Branch 6 taken 1280 times.
✓ Branch 7 taken 1588 times.
26877 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
29236 {
29237 1588 cmbid = MAPCOMBO(x+8,y+16);
29238 1588 cmb = &combobuf[cmbid];
29239 1588 custom_spd = cmb->usrflags&cflag2;
29240 1588 ctype=(cmb->type);
29241 1588 deltax=combo_class_buf[ctype].conveyor_x_speed;
29242 1588 deltay=combo_class_buf[ctype].conveyor_y_speed;
29243
2/4
✓ Branch 0 taken 1588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1588 times.
✗ Branch 3 not taken.
1588 if ((deltax != 0 || deltay != 0) && custom_spd)
29244 {
29245 deltax = zslongToFix(cmb->attributes[0]);
29246 deltay = zslongToFix(cmb->attributes[1]);
29247 }
29248 1588 }
29249
29250
2/4
✓ Branch 0 taken 26877 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26877 times.
26877 if(deltax!=0||deltay!=0)
29251 {
29252 is_on_conveyor=true;
29253 }
29254 26877 else return;
29255
29256 bool movedx = false, movedy = false;
29257 if(cmb->usrflags&cflag4) //Smart corners
29258 {
29259 if(deltay<0)
29260 {
29261 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29262 execute(info);
29263
29264 if(!info.isUnwalkable())
29265 {
29266 movedy = true;
29267 zfix step(0);
29268
29269 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29270 {
29271 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29272 {
29273 yoff=int32_t(y-step)&7;
29274
29275 if(!yoff) break;
29276
29277 step++;
29278 }
29279 }
29280 else
29281 {
29282 step=abs(deltay);
29283 }
29284
29285 y=y-step;
29286 hs_starty-=step.getInt();
29287
29288 for(int32_t j=0; j<chainlinks.Count(); j++)
29289 {
29290 chainlinks.spr(j)->y-=step;
29291 }
29292
29293 if(Lwpns.idFirst(wHookshot)>-1)
29294 {
29295 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29296 }
29297
29298 if(Lwpns.idFirst(wHSHandle)>-1)
29299 {
29300 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29301 }
29302 }
29303 }
29304 else if(deltay>0)
29305 {
29306 info = walkflag(x,y+15+2,2,down);
29307 execute(info);
29308
29309 if(!info.isUnwalkable())
29310 {
29311 movedy = true;
29312 zfix step(0);
29313
29314 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29315 {
29316 while(step<abs(deltay))
29317 {
29318 yoff=int32_t(y+step)&7;
29319
29320 if(!yoff) break;
29321
29322 step++;
29323 }
29324 }
29325 else
29326 {
29327 step=abs(deltay);
29328 }
29329
29330 y=y+step;
29331 hs_starty+=step.getInt();
29332
29333 for(int32_t j=0; j<chainlinks.Count(); j++)
29334 {
29335 chainlinks.spr(j)->y+=step;
29336 }
29337
29338 if(Lwpns.idFirst(wHookshot)>-1)
29339 {
29340 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29341 }
29342
29343 if(Lwpns.idFirst(wHSHandle)>-1)
29344 {
29345 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29346 }
29347 }
29348 }
29349
29350 if(deltax<0)
29351 {
29352 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29353 execute(info);
29354
29355 if(!info.isUnwalkable())
29356 {
29357 movedx = true;
29358 zfix step(0);
29359
29360 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29361 {
29362 while(step<abs(deltax))
29363 {
29364 xoff=int32_t(x-step)&7;
29365
29366 if(!xoff) break;
29367
29368 step++;
29369 }
29370 }
29371 else
29372 {
29373 step=abs(deltax);
29374 }
29375
29376 x=x-step;
29377 hs_startx-=step.getInt();
29378
29379 for(int32_t j=0; j<chainlinks.Count(); j++)
29380 {
29381 chainlinks.spr(j)->x-=step;
29382 }
29383
29384 if(Lwpns.idFirst(wHookshot)>-1)
29385 {
29386 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29387 }
29388
29389 if(Lwpns.idFirst(wHSHandle)>-1)
29390 {
29391 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29392 }
29393 }
29394 }
29395 else if(deltax>0)
29396 {
29397 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29398 execute(info);
29399
29400 if(!info.isUnwalkable())
29401 {
29402 movedx = true;
29403 zfix step(0);
29404
29405 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29406 {
29407 while(step<abs(deltax))
29408 {
29409 xoff=int32_t(x+step)&7;
29410
29411 if(!xoff) break;
29412
29413 step++;
29414 }
29415 }
29416 else
29417 {
29418 step=abs(deltax);
29419 }
29420
29421 x=x+step;
29422 hs_startx+=step.getInt();
29423
29424 for(int32_t j=0; j<chainlinks.Count(); j++)
29425 {
29426 chainlinks.spr(j)->x+=step;
29427 }
29428
29429 if(Lwpns.idFirst(wHookshot)>-1)
29430 {
29431 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29432 }
29433
29434 if(Lwpns.idFirst(wHSHandle)>-1)
29435 {
29436 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29437 }
29438 }
29439 }
29440 if(deltax && !movedx)
29441 y = COMBOY(pos);
29442 if(deltay && !movedy)
29443 x = COMBOX(pos);
29444 }
29445 if(!movedy)
29446 {
29447 if(deltay<0)
29448 {
29449 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29450 execute(info);
29451
29452 if(!info.isUnwalkable())
29453 {
29454 movedy = true;
29455 zfix step(0);
29456
29457 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29458 {
29459 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29460 {
29461 yoff=int32_t(y-step)&7;
29462
29463 if(!yoff) break;
29464
29465 step++;
29466 }
29467 }
29468 else
29469 {
29470 step=abs(deltay);
29471 }
29472
29473 y=y-step;
29474 hs_starty-=step.getInt();
29475
29476 for(int32_t j=0; j<chainlinks.Count(); j++)
29477 {
29478 chainlinks.spr(j)->y-=step;
29479 }
29480
29481 if(Lwpns.idFirst(wHookshot)>-1)
29482 {
29483 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29484 }
29485
29486 if(Lwpns.idFirst(wHSHandle)>-1)
29487 {
29488 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29489 }
29490 }
29491 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
29492 }
29493 else if(deltay>0)
29494 {
29495 info = walkflag(x,y+15+2,2,down);
29496 execute(info);
29497
29498 if(!info.isUnwalkable())
29499 {
29500 movedy = true;
29501 zfix step(0);
29502
29503 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29504 {
29505 while(step<abs(deltay))
29506 {
29507 yoff=int32_t(y+step)&7;
29508
29509 if(!yoff) break;
29510
29511 step++;
29512 }
29513 }
29514 else
29515 {
29516 step=abs(deltay);
29517 }
29518
29519 y=y+step;
29520 hs_starty+=step.getInt();
29521
29522 for(int32_t j=0; j<chainlinks.Count(); j++)
29523 {
29524 chainlinks.spr(j)->y+=step;
29525 }
29526
29527 if(Lwpns.idFirst(wHookshot)>-1)
29528 {
29529 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29530 }
29531
29532 if(Lwpns.idFirst(wHSHandle)>-1)
29533 {
29534 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29535 }
29536 }
29537 else checkdamagecombos(x,y+15);
29538 }
29539 }
29540 if(!movedx)
29541 {
29542 if(deltax<0)
29543 {
29544 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29545 execute(info);
29546
29547 if(!info.isUnwalkable())
29548 {
29549 movedx = true;
29550 zfix step(0);
29551
29552 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29553 {
29554 while(step<abs(deltax))
29555 {
29556 xoff=int32_t(x-step)&7;
29557
29558 if(!xoff) break;
29559
29560 step++;
29561 }
29562 }
29563 else
29564 {
29565 step=abs(deltax);
29566 }
29567
29568 x=x-step;
29569 hs_startx-=step.getInt();
29570
29571 for(int32_t j=0; j<chainlinks.Count(); j++)
29572 {
29573 chainlinks.spr(j)->x-=step;
29574 }
29575
29576 if(Lwpns.idFirst(wHookshot)>-1)
29577 {
29578 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29579 }
29580
29581 if(Lwpns.idFirst(wHSHandle)>-1)
29582 {
29583 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29584 }
29585 }
29586 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
29587 }
29588 else if(deltax>0)
29589 {
29590 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29591 execute(info);
29592
29593 if(!info.isUnwalkable())
29594 {
29595 movedx = true;
29596 zfix step(0);
29597
29598 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29599 {
29600 while(step<abs(deltax))
29601 {
29602 xoff=int32_t(x+step)&7;
29603
29604 if(!xoff) break;
29605
29606 step++;
29607 }
29608 }
29609 else
29610 {
29611 step=abs(deltax);
29612 }
29613
29614 x=x+step;
29615 hs_startx+=step.getInt();
29616
29617 for(int32_t j=0; j<chainlinks.Count(); j++)
29618 {
29619 chainlinks.spr(j)->x+=step;
29620 }
29621
29622 if(Lwpns.idFirst(wHookshot)>-1)
29623 {
29624 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29625 }
29626
29627 if(Lwpns.idFirst(wHSHandle)>-1)
29628 {
29629 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29630 }
29631 }
29632 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
29633 }
29634 }
29635 if(movedx || movedy)
29636 {
29637 if(cmb->usrflags&cflag1)
29638 is_conveyor_stunned = rate;
29639 if(cmb->usrflags&cflag3)
29640 {
29641 if(abs(deltax) > abs(deltay))
29642 dir = (deltax > 0) ? right : left;
29643 else dir = (deltay > 0) ? down : up;
29644 }
29645 }
29646 }
29647 79959 }
29648
29649 void HeroClass::setNayrusLoveShieldClk(int32_t newclk)
29650 {
29651 NayrusLoveShieldClk=newclk;
29652
29653 if(decorations.idCount(dNAYRUSLOVESHIELD)==0)
29654 {
29655 decoration *dec;
29656 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29657 decorations.spr(decorations.Count()-1)->misc=0;
29658 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29659 dec=(decoration *)decorations.spr(decorations.Count()-1);
29660 decorations.spr(decorations.Count()-1)->misc=1;
29661 }
29662 }
29663
29664 175 int32_t HeroClass::getNayrusLoveShieldClk()
29665 {
29666 175 return NayrusLoveShieldClk;
29667 }
29668
29669 int32_t HeroClass::getHoverClk()
29670 {
29671 return hoverclk;
29672 }
29673
29674 263899 int32_t HeroClass::getHoldClk()
29675 {
29676 263899 return holdclk;
29677 }
29678
29679 75737 int32_t HeroClass::getLastLensID(){
29680 75737 return last_lens_id;
29681 }
29682
29683 void HeroClass::setLastLensID(int32_t p_item){
29684 last_lens_id = p_item;
29685 }
29686
29687 708156 bool HeroClass::getOnSideviewLadder()
29688 {
29689 708156 return on_sideview_ladder;
29690 }
29691
29692 64 void HeroClass::setOnSideviewLadder(bool val)
29693 {
29694
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 5 times.
64 if(val)
29695 {
29696 5 fall = fakefall = hoverclk = jumping = 0;
29697 5 hoverflags = 0;
29698 5 inair = false;
29699 5 }
29700 64 on_sideview_ladder = val;
29701 64 }
29702
29703 24918 bool HeroClass::canSideviewLadder(bool down)
29704 {
29705
2/2
✓ Branch 0 taken 23182 times.
✓ Branch 1 taken 1736 times.
24918 if(!isSideViewHero()) return false;
29706
1/2
✓ Branch 0 taken 1736 times.
✗ Branch 1 not taken.
1736 if(jumping < 0) return false;
29707
3/4
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 868 times.
✗ Branch 3 not taken.
1736 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29708 {
29709 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29710 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
29711 }
29712 //Are you presently able to climb a sideview ladder?
29713 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29714 //y+0 checks your top-half for large hitbox; y+8 for small
29715 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29716 //y+16 check is for going down onto a ladder you are standing on.
29717
2/2
✓ Branch 0 taken 1458 times.
✓ Branch 1 taken 278 times.
3123 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
29718
4/4
✓ Branch 0 taken 1387 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 84 times.
1458 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
29719
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✓ Branch 2 taken 435 times.
✓ Branch 3 taken 868 times.
✓ Branch 4 taken 868 times.
✗ Branch 5 not taken.
2171 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
29720 24918 }
29721
29722 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
29723 {
29724 if(!isSideViewHero()) return false;
29725 if(jumping < 0) return false;
29726 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29727 {
29728 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29729 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
29730 }
29731 //Are you presently able to climb a sideview ladder?
29732 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29733 //y+0 checks your top-half for large hitbox; y+8 for small
29734 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29735 //y+16 check is for going down onto a ladder you are standing on.
29736 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
29737 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
29738 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
29739 }
29740
29741 62729 void HeroClass::execute(HeroClass::WalkflagInfo info)
29742 {
29743 62729 int32_t flags = info.getFlags();
29744
29745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62729 times.
62729 if(flags & WalkflagInfo::CLEARILSWIM)
29746 ilswim =false;
29747
2/2
✓ Branch 0 taken 62722 times.
✓ Branch 1 taken 7 times.
62729 else if(flags & WalkflagInfo::SETILSWIM)
29748 7 ilswim = true;
29749
29750
1/2
✓ Branch 0 taken 62729 times.
✗ Branch 1 not taken.
62729 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
29751 {
29752 charging = 0;
29753 attackclk = 0;
29754 }
29755
29756
1/2
✓ Branch 0 taken 62729 times.
✗ Branch 1 not taken.
62729 if(flags & WalkflagInfo::SETDIR)
29757 {
29758 dir = info.getDir();
29759 }
29760
29761
1/2
✓ Branch 0 taken 62729 times.
✗ Branch 1 not taken.
62729 if(flags & WalkflagInfo::SETHOPCLK)
29762 {
29763 hopclk = info.getHopClk();
29764 }
29765
29766
1/2
✓ Branch 0 taken 62729 times.
✗ Branch 1 not taken.
62729 if(flags & WalkflagInfo::SETHOPDIR)
29767 {
29768 hopdir = info.getHopDir();
29769 }
29770
29771 62729 }
29772
29773 106113 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
29774 {
29775 106113 HeroClass::WalkflagInfo ret;
29776 106113 ret.newhopclk = newhopclk;
29777 106113 ret.newdir = newdir;
29778
2/2
✓ Branch 0 taken 88196 times.
✓ Branch 1 taken 17917 times.
106113 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29779
29780 106113 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
29781 106113 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
29782 106113 ret.flags = flags1 | flags2;
29783 106113 return ret;
29784 }
29785
29786 12 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
29787 {
29788 12 HeroClass::WalkflagInfo ret;
29789 12 ret.newhopclk = newhopclk;
29790 12 ret.newdir = newdir;
29791
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29792
29793 12 ret.flags = flags & other.flags;
29794 12 return ret;
29795 }
29796
29797 12 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
29798 {
29799 12 HeroClass::WalkflagInfo ret;
29800 12 ret.newhopclk = newhopclk;
29801 12 ret.newdir = newdir;
29802 12 ret.newhopdir = newhopdir;
29803
29804 12 ret.flags = flags ^ UNWALKABLE;
29805 12 return ret;
29806 }
29807
29808 void HeroClass::explode(int32_t type)
29809 {
29810 static int32_t tempx, tempy;
29811 static byte herotilebuf[256];
29812 int32_t ltile=0;
29813 int32_t lflip=0;
29814 bool shieldModify=true;
29815 unpack_tile(newtilebuf, tile, flip, true);
29816 memcpy(herotilebuf, unpackbuf, 256);
29817 tempx=Hero.getX();
29818 tempy=Hero.getY();
29819 for(int32_t i=0; i<16; ++i)
29820 {
29821 for(int32_t j=0; j<16; ++j)
29822 {
29823 if(herotilebuf[i*16+j])
29824 {
29825 if(type==0) // Twilight
29826 {
29827 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
29828 int32_t k=particles.Count()-1;
29829 particle *p = (particles.at(k));
29830 p->step=3;
29831 }
29832 else if(type ==1) // Sands of Hours
29833 {
29834 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
29835 int32_t k=particles.Count()-1;
29836 particle *p = (particles.at(k));
29837 p->step=4;
29838
29839 if(zc_oldrand()%10 < 2)
29840 {
29841 p->color=1;
29842 p->cset=0;
29843 }
29844 }
29845 else
29846 {
29847 particles.add(new pFaroresWindDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
29848
29849 int32_t k=particles.Count()-1;
29850 particle *p = (particles.at(k));
29851 p->angular=true;
29852 p->angle=zc_oldrand();
29853 p->step=(((double)j)/8);
29854 p->yofs=Hero.getYOfs();
29855 }
29856 }
29857 }
29858 }
29859 }
29860
29861 4 void HeroClass::SetSwim()
29862 {
29863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (CanSideSwim())
29864 {
29865 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
29866 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29867 if (get_bit(quest_rules,qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
29868 }
29869 4 else {action=swimming; FFCore.setHeroAction(swimming);}
29870 4 }
29871
29872 700 void HeroClass::SetAttack()
29873 {
29874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 700 times.
700 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29875 700 else {action=attacking; FFCore.setHeroAction(attacking);}
29876 700 }
29877
29878 679061 bool HeroClass::IsSideSwim()
29879 {
29880
6/12
✓ Branch 0 taken 679061 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 679061 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 679061 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 679061 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 679061 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 679061 times.
679061 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
29881 }
29882
29883 15267 bool HeroClass::CanSideSwim()
29884 {
29885
1/2
✓ Branch 0 taken 15267 times.
✗ Branch 1 not taken.
15267 return (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM));
29886 }
29887
29888 62422 int32_t HeroClass::getTileModifier()
29889 {
29890 62422 return item_tile_mod() + bunny_tile_mod();
29891 }
29892 void HeroClass::setImmortal(int32_t nimmortal)
29893 {
29894 immortal = nimmortal;
29895 }
29896 void HeroClass::kill(bool bypassFairy)
29897 {
29898 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
29899 }
29900 174542 bool HeroClass::sideview_mode() const
29901 {
29902
3/4
✓ Branch 0 taken 21014 times.
✓ Branch 1 taken 153528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21014 times.
174542 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
29903 }
29904 10647 bool HeroClass::is_unpushable() const
29905 {
29906 10647 return toogam;
29907 }
29908 /*** end of hero.cpp ***/
29909
29910
29911
29912
29913